marking on image
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to know how can I mark on a threshold segmented image in the segment of it which one of the morphological extracted features is greater than a specified threshold?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 7 Apr. 2012
Please look over this demo and see how you use ismember to select objects bigger than 95 pixels, and how you use just normal indexing/assignment to set all those objects to 254 in a single line of code. This is an adaptation of my Image Segmentation tutorial at my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Create sample image.
originalImage = propsSynthesizeImage;
subplot(2, 2, 1);
imshow(originalImage);
impixelinfo; % Allow cursor to show gray levels.
title('Synthetic Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Threshold the image to get a binary image (only 0's and 1's) of class "logical."
thresholdValue = 190;
binaryImage = originalImage > thresholdValue; % Bright objects will be the chosen if you use >.
subplot(2, 2, 2);
imshow(binaryImage);
title('Binary Image', 'FontSize', fontSize);
% Label the image.
[labeledImage numberOfOriginalBlobs] = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
% Get all the blob properties. Can only pass in originalImage in version R2008a and later.
blobMeasurements = regionprops(labeledImage, originalImage, 'all');
% Now I'll demonstrate how to select certain blobs based using the ismember function.
% Let's say that we wanted to find only those blobs
% with an area greater than 95 pixels.
allBlobAreas = [blobMeasurements.Area];
% Get a list of the blobs that meet our criteria and we need to keep.
allowableAreaIndexes = allBlobAreas > 95; % Take the large objects.
keeperIndexes = find(allowableAreaIndexes);
% Extract only those blobs that meet our criteria, and
% eliminate those blobs that don't meet our criteria.
% Note how we use ismember() to do this.
keeperBlobsImage = ismember(labeledImage, keeperIndexes);
% Re-label with only the keeper blobs kept.
[areasGT95Image numberOfBlobs] = bwlabel(keeperBlobsImage, 8); % Label each blob so we can make measurements of it
% Now we're done. We have a labeled image of blobs that meet our specified criteria.
subplot(2, 2, 3);
% Convert the labeled image back to a binary image.
binary95 = areasGT95Image > 0;
imshow(binary95, []);
title('"Keeper" blobs larger than 95 pixels', 'FontSize', fontSize);
% Make those pixels have a value of 254 in the original image.
outputImage = originalImage; % Make a copy
outputImage(binary95) = 254; % Change the copy.
% Display the final output image.
subplot(2, 2, 4);
imshow(outputImage, []);
title('Original blobs larger than 95 pixels = 254', 'FontSize', fontSize);
2 Kommentare
Image Analyst
am 10 Apr. 2012
It might have been what you wanted if you said what you wanted. "which one of the morphological extracted features is greater than a specified threshold" is not exactly very specific.
Weitere Antworten (3)
bahar h
am 14 Apr. 2012
1 Kommentar
Image Analyst
am 14 Apr. 2012
I don't know how "some points are displayed" but if you used plot() or some other type of graphics function to put stuff into the overlay, you can just call axes() to set the current axes, then call plot(), then call hold on, then call plot again to plot all your other points that you want to be on the same image. (Don't switch to another axes or else they'll appear there instead.)
On the other hand if you want to superimpose all the images, you can do this:
meanImage = (single(image1) + single(image2) + ..... + single(image9))/9;
imshow(meanImage, []);
sneha
am 18 Apr. 2012
hi expert......... i m working on car license plate recognition...can u tell me how cold i recognize characters fron license plate using OCR...plz ans me
1 Kommentar
Image Analyst
am 18 Apr. 2012
You're best off searching for license plate or LPR in this forum. This question is asked almost daily here.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!