필터 지우기
필터 지우기

How to labels each cell in image? i upload the input images and the output masks which i wants from the input image.

조회 수: 6 (최근 30일)
1(110).png
  댓글 수: 8
Image Analyst
Image Analyst 2018년 12월 1일
편집: Image Analyst 2018년 12월 1일
There is no function unit8. You probably meant uint8().

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 12월 1일
Try this code to label the regions and loop through and show you the regions one at a time:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 18;
binaryImage = imread('index.png');
subplot(2, 2, 1);
imshow(binaryImage); % Saved image is already logical/binary.
axis('on', 'image');
title('Original Binary Image', 'FontSize', fontSize);
filledImage = imfill(binaryImage,'holes');
subplot(2, 2, 2);
imshow(filledImage);
axis('on', 'image');
title('Filled Binary Image', 'FontSize', fontSize);
subplot(2, 2, 3);
[labeledImage, numberOfRegions] = bwlabel(filledImage);
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
imshow(coloredLabels);
axis('on', 'image');
caption = sprintf('Labeled Image has %d Regions', numberOfRegions);
title(caption, 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Make measurements
props = regionprops(labeledImage, 'Image', 'BoundingBox');
% Loop over all blobs, showing them one at a time.
subplot(2, 2, 4);
for k = 1 : numberOfRegions
thisBlob = props(k).Image;
imshow(thisBlob);
axis('on', 'image');
[rows, columns] = size(thisBlob);
caption = sprintf('Region #%d is %d rows by %d columns', k, rows, columns);
title(caption, 'FontSize', fontSize);
promptMessage = sprintf('Do you want to Continue,\nor Quit?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
break;
end
end
0000 Screenshot.png
  댓글 수: 5
Image Analyst
Image Analyst 2018년 12월 2일
There is a function called imwrite() that you should learn of.
If you want images where there is just one blob per image, save thisBlob in the loop with imwrite() and a unique filename
filename = sprintf('Blob %d.png', k);
imwrite(thisBlob, filename);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by