2023.10.26
Today's agenda
1. image binarization
2. mopology
3. labling and outer line detection
Make pixels on image make to only 0 or 255 value(true or false)
it can be seperate background and object
Make a image into ROI(Reason Of Interest) and Non-ROI space
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type);
parameters
return value
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int t_value = 128;
void on_trackbar_threshold(int, void*);
Mat src, dst;
int main(int argc, char* argv[])
{
String filename = "neutrophils.png";
if (argc > 1) {
filename = argv[1];
}
src = imread(filename, IMREAD_GRAYSCALE);
if (src.empty()) {
cerr << "Image load failed!" << endl;
return -1;
}
namedWindow("src");
imshow("src", src);
namedWindow("dst");
createTrackbar("Threshold", "dst", &t_value, 255, on_trackbar_threshold);
on_trackbar_threshold(0, 0); // Call the function to initialize
waitKey();
}
void on_trackbar_threshold(int, void*)
{
threshold(src, dst, t_value, 255, THRESH_BINARY | THRESH_OTSU);
imshow("dst", dst);
}
problem of local binarization
week of different brightness image
For global binarazation, tear a part from a image like a 16 or 25 parts and do each part and local binarization
void adaptiveThreshold(InputArray src, OutputArray dst, double maxValue, int adaptiveMethod, int thresholeType, int blockSize, double C);
parameters
detection of object in shape space that pre/post processing
void erode(InputArray src, OutputArray dst, InputArray kernel, Point anchor = Point(-1, 1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar& borderValue = morphologyDefaultBorderValue());
paramerers
void dialate(InputArray src, OutputArray dst, InputArray kernel, Point anchor = Point(-1, 1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar& borderValue = morphologyDefaultBorderValue());
paramerers
Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1, 1)); ``
paramerters
return value
opening = erosion -> dilation
closing = dilation -> erosion
void morphologyEx(InputArray src, OutputArray dst, int op, InputArray kernel, Point anchor = Point(-1, 1), int iterations = 1, int borderType = BORDER_CONSTANT, const Scalar& borderValue = morphologyDefaultBorderValue());
parameters