how to find the least pixel intensity value for each connected component?

조회 수: 4 (최근 30일)
Binary image:
finalcandidates.png
Green image:
Ig.jpg
I have a binary image with some pixels as 1 and some as 0 forming a image of group of connected components(white spots within the black image).I need to find the intensities of the pixels of these white spots in other image(green image) and find the pixel with lowest intensity and its value in the green image.I need to find the lowest intensity pixel and its value in the green image for all the white clusters in the binary image.
Can somebody please help me how to find it?
Thank you.
I am enclosing the binary image as finalcandidates,png and the green image as Ig.png.

채택된 답변

Image Analyst
Image Analyst 2020년 1월 8일
See demo below. Adapt as needed:
grayImage = imread('coins.png');
subplot(2, 2, 1);
imshow(grayImage);
subplot(2, 2, 2);
histogram(grayImage)
binaryImage = imfill(grayImage > 90, 'holes');
binaryImage = bwareafilt(binaryImage, 10);
subplot(2, 2, 3);
imshow(binaryImage);
subplot(2, 2, 4);
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(labeledImage, grayImage, 'PixelValues', 'PixelList')
for k = 1 : numBlobs
% Fin the min value of this blob's pixel values.
thisBlobsMin = min(props(k).PixelValues);
% Get locations in this blob
mask = ismember(labeledImage, k);
maskedImage = grayImage .* uint8(mask);
% Find all the rows and columns where it appears
[rows, columns] = find(maskedImage == thisBlobsMin);
imshow(maskedImage);
axis('on', 'image');
hold on;
plot(columns, rows, 'r+', 'LineWidth', 2, 'MarkerSize', 15);
hold off
caption = sprintf('Showing cross at %d mins for blob #%d of %d.\n', ...
length(rows), k, numBlobs);
title(caption, 'FontSize', 12);
fprintf('%s\n', caption);
end
fprintf('Done!\n');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by