Şu anda sahip olduğum bu sorunu çözmek için biraz yardıma ihtiyacım var. Ben sadece farklı şeyler, aynı zamanda Mavi, Yeşil ve Kırmızı temsil eden 3 görüntü var. Onları birleştirmem ve renkli bir görüntü almam gerekiyor. Ben opencv ve C++ kullanıyorum, ama şimdi bunu çözemediğim bu sorunu yaşıyorum. Kenar algılama üzerinde çalışma GEREKLİ:İHTİYAÇ: .İlk Sobel türevini bir kere x ve y yönünde bir kez hesaplayın ve bu iki (her kanal için) birleştirin
---- Güncelleme ---- ben bu sonucu bad example
olsun Ama böyle olmalı bazı yeni kodu
Sobel(img_r, x, CV_16S, 1, 0);
Sobel(img_r, y, CV_16S, 0, 1);
//Compute the L1 norm
sobel_L1_norm = abs(x)+abs(y);
//Find Sobel max value
minMaxLoc(sobel_L1_norm, &min, &max);
sobel_L1_norm.convertTo(sobel_image, CV_32F, 255.0/(max - min), -min * 255.0/(max - min));
threshold(sobel_image, edgeThreshold, min, 255, THRESH_BINARY);
edgeThreshold.copyTo(img_r_edge);
yazdı. correct one
---- TAM KOD -----
Mat img_r = imread(input_path + "/01.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_g = imread(input_path + "/02.png", CV_LOAD_IMAGE_GRAYSCALE);
Mat img_b = imread(input_path + "/03.png", CV_LOAD_IMAGE_GRAYSCALE);
// Edge Images
Mat img_r_edge = Mat::zeros(img_r.size(), CV_8UC1);
Mat img_g_edge = Mat::zeros(img_g.size(), CV_8UC1);
Mat img_b_edge = Mat::zeros(img_b.size(), CV_8UC1);
std::cout << "Step 1 - calculating edge images... ";
// TODO: 1) Calculate the 1st Sobel derivative once in x and once in y direction and combine these two
// (for every channel).
Mat x;
Mat y;
Mat abs_x;
Mat abs_y;
Mat sobel_L1_norm;
Mat sobel_image;
Mat edgeThreshold;
double min, max; //Finding min and max Sobel valuye;
//---------------------------------------------------
Sobel(img_r, x, CV_16S, 1, 0);
Sobel(img_r, y, CV_16S, 0, 1);
//Compute the L1 norm
sobel_L1_norm = abs(x)+abs(y);
//Find Sobel max value
minMaxLoc(sobel_L1_norm, &min, &max);
sobel_L1_norm.convertTo(sobel_image, CV_32F, 255.0/(max - min), -min * 255.0/(max - min));
threshold(sobel_image, edgeThreshold, min, 255, THRESH_BINARY);
edgeThreshold.copyTo(img_r_edge);
//----------------------------------------------------
// 2) Normalize every gradient image and convert the results to CV_8UC1.
// 3) Threshold the retrieved (normalized) gradient images using the parameter "edgeThreshold".
// 4) Save the results in the cv::Mats below.
imwrite(out_r_edge_filename, sobel);
imwrite(out_g_edge_filename, img_g_edge);
imwrite(out_b_edge_filename, img_b_edge);
_How_ bunları birleştirmek ki?Her gri görüntü için 'büyüklüğü' hesaplar ve daha sonra 3 büyüklüğü eklerim. (kırpma önlemek için float görüntüleri kullanın) – Miki
addWeighted fonksiyonu ile çalışması gerekir.Ama gerçekten hiçbir ipucu ile değilim şimdi – twistedhat
Gönderdim ve bazı örnekler ile cevap. Kodu yazmayı denemeden not aldığımı not edin, hatalar olabilir ... ama bunun için bildiğim – Miki