Otsu's Threshold Question
古いコメントを表示
I am attempting to create a classifier which detects the solar panels in a series of images. To create the training data i have been using Otsu's threshold to seperate the blue solar cells from the white grids (see first image below). I have been able to isolate the solar panels from the background, as seen in the second image, and then use the threshold to seperate the classes. I, however, want the blue cells to be highlighted instead of the white grid lines. Does anyone know how to do this? Below is also the code I have been running and the output images at various points.

RGB = imread('1-108.png'); %input image (as seen above)
GT = imread('1-108gt.png'); %original groundtruth of input image which highlights both grid and cell
I = rgb2gray(RGB); %convert RGB to intensity
[row,col] = size(I);
com = uint8(zeros(size(I)));
%when the groundtruth is logic 1, replace this with the corresponding intensity pixel
for r=1:row
for c=1:col
if GT(r,c)==1
com(r,c) = I(r,c);
else
com(r,c) = 0;
end
end
end
figure
imshow(com)
[counts, x] = imhist(com,16);
figure
stem(x,counts)
T = otsuthresh(counts(2:16,:)); %does not consider the first column as this is all the background pixels
BW = imbinarize(com,T);
figure
imshow(BW)
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Thresholding についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



