목록영상처리 (17)
어제보다 나은 내가 되자

#include using namespace std; using namespace cv; void on_trackbar(int pos, void* userdata) { Mat src = *(Mat*)userdata; int blocksize = pos; if (blocksize % 2 == 0) blocksize--; // blocksize is possible when odd if (blocksize < 3) blocksize = 3; // blocksize minimum size Mat dst; adaptiveThreshold(src, dst, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, blocksize, 5); // threshold = gaussian a..

#include using namespace std; using namespace cv; void on_threshold(int pos, void* userdata) { Mat src = *(Mat*)userdata; Mat dst; threshold(src, dst, pos, 255, THRESH_BINARY); imshow("dst", dst); } int main(int argc, char* argv[]) { Mat src; src = imread("neutrophils.png", IMREAD_GRAYSCALE); imshow("src", src); namedWindow("dst"); createTrackbar("Threshold", "dst", 0, 255, on_threshold, (void*)..

#include using namespace std; using namespace cv; int main() { Mat src, src_ycrcb, mask; src = imread("kyeong.jpg"); mask = imread("mask.jpg",IMREAD_GRAYSCALE); cvtColor(src, src_ycrcb, COLOR_BGR2YCrCb); // BGR to YCrCb in src_ycrcb Mat hist; int channels[] = { 1,2 }; int histSize[] = { 128,128 }; float cr_range[] = { 0,256 }; float cb_range[] = { 0,256 }; const float* ranges[] = { cr_range,cb_r..

#include using namespace std; using namespace cv; //int lower_hue = 40, upper_hue = 80; int lower_hue, upper_hue; Mat src, src_hsv, mask; void on_hue_changed(int, void*) { Scalar lowerb(lower_hue, 100, 0); Scalar upperb(upper_hue, 255, 255); inRange(src_hsv, lowerb, upperb, mask); // R 160~179 // G 40~80 // B 100~140 imshow("mask", mask); } int main(int argc, char* argv[]) { src = imread("candie..

#include using namespace std; using namespace cv; int main() { Mat src = imread("../image/pepper.bmp"); Mat src_ycrcb; cvtColor(src, src_ycrcb, COLOR_BGR2YCrCb);// BRG->YCrCb 후 src_ycrcb에 저장 vector ycrcb_planes; split(src_ycrcb, ycrcb_planes);// 채널 분리 equalizeHist(ycrcb_planes[0], ycrcb_planes[0]); Mat dst_ycrcb; merge(ycrcb_planes, dst_ycrcb);// 분리한 채널 병합 Mat dst; cvtColor(dst_ycrcb, dst, COLOR..

#include using namespace std; using namespace cv; int main() { Mat src = imread("candies.png"); // 컬러영상으로 불러옴 vector bgr_planes; // Mat 자료형의 vector 생성 split(src, bgr_planes); // 입력 영상 분리해서 vecotr에 넣음 Mat dst; merge(bgr_planes, dst); // 분리된 영상 합치기 imshow("src", src); imshow("B_plane", bgr_planes[0]); imshow("G_plane", bgr_planes[1]); imshow("R_plane", bgr_planes[2]); imshow("Merge", dst); waitKey..

#include using namespace cv; using namespace std; int main() { Mat src = imread("../image/apple.jpg", IMREAD_COLOR); //Mat dst(src.rows, src.cols, src.type()); Mat dst = Scalar(255, 255, 255) - src; /*for (int j = 0; j < src.rows; j++) { for (int i = 0; i < src.cols; i++) { Vec3b& p1 = src.at(j, i); Vec3b& p2 = src.at(j, i); p2[0] = 255 - p1[0]; p2[1] = 255 - p1[1]; p2[2] = 255 - p1[2]; } }*/ im..