|
HI ImageAnalyst:
Thank you so much!!!
All my problem are solved !!!
^_^
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <9723e020-f741-435d-bca5-6cceb3e0814b@33g2000vbe.googlegroups.com>...
> On Sep 23, 7:07?am, "Yi " <heyinba0...@hotmail.com> wrote:
> > Hi ImageAnalyst:
> > I don't understand what is "original(input)" meaning?
> > original()---- is it a function?
> > thanks
>
> -------------------------------------------------------------------------
> Yi:
> You have an image where blobs touch the border.
> Let's call this the "original image." I just put it in parentheses to
> mean that I'm giving an alternate name for it.
> See http://en.wikipedia.org/wiki/Parenthesis_(rhetoric) for an
> explanation of a "parenthesis" in a rhetorical sentence: "An
> explanatory or qualifying word, clause, or sentence inserted into a
> passage with which it doesn't necessarily have any grammatical
> connection, and from which it is usually marked off by round or square
> brackets, dashes, or commas according to the Oxford English
> Dictionary."
>
> Now let's run that image though imclearborder() and get back an image
> with no border blobs in it.
> Let's call that image the "output image."
> outputImage = imclearborder(inputImage);
> Make sense? Now simply subtract them:
> borderBlobs = inputImage- outputImage;
>
> Here's some more demo code. Just copy, paste, fix lines broken by the
> newsreader, and run.
> Best wishes,
> ImageAnalyst
>
> clc;
> %clear all;
> close all;
> workspace;
> % Read in demo image
> originalImageX = imread('testimageg.jpg');
> originalImage = rgb2gray(originalImageX);
> subplot(3,2,1);
> imshow(originalImage, []);
> title('Original Image');
>
> % Make a blob touch the border
> originalImage(1:40, 100:140) = 0;
> originalImage(180:230, 200:end) = 0;
> subplot(3,2,2);
> imshow(originalImage, []);
> title('Image with border blobs');
>
> thresholdValue = 150;
> binaryImage = originalImage < thresholdValue;
> subplot(3,2,3);
> imshow(binaryImage, []);
> title('Binarized Image');
>
>
> labeledImage = bwlabel(binaryImage, 8);
> subplot(3,2,4);
> imshow(labeledImage, []);
> title('Labeled Image');
>
> blobMeasurements = regionprops(labeledImage, originalImage,
> 'EulerNumber', 'Centroid');
> numberOfBlobs = size(blobMeasurements, 1);
> for blobNumber = 1 : numberOfBlobs
> thisBlobsEulerNumber = int32(blobMeasurements
> (blobNumber).EulerNumber); % Get list of pixels in current blob.
> numberOfHoles = int32(1 - thisBlobsEulerNumber);
> blobCentroid = blobMeasurements
> (blobNumber).Centroid; % Get centroid.
> labelString = sprintf('Blob #%d', blobNumber);
> text(blobCentroid(1), blobCentroid(2), labelString, 'Color',
> [1 .25 .10], 'FontSize', 14);
> fprintf(1,'Blob #%d Euler Number = %d, number of Holes = %d \n',
> blobNumber, thisBlobsEulerNumber, numberOfHoles);
> end
>
> % Now get rid of the blobs that touch the border
> noBorderBlobs = imclearborder(binaryImage);
> subplot(3,2,5);
> imshow(noBorderBlobs, []);
> title('Border Blobs Removed');
>
> % Now find the blobs that touched the border
> borderBlobs = binaryImage - noBorderBlobs;
> subplot(3,2,6);
> imshow(borderBlobs, []);
> title('Border Blobs Only');
>
> % Relabel and measure ONLY the border blobs
> labeledImageB = bwlabel(borderBlobs, 8);
>
> blobMeasurementsB = regionprops(labeledImageB, originalImage, 'All');
> numberOfBlobs = size(blobMeasurementsB, 1);
>
> for blobNumber = 1 : numberOfBlobs
> thisBlobsEulerNumber = int32(blobMeasurementsB
> (blobNumber).EulerNumber); % Get list of pixels in current blob.
> numberOfHoles = int32(1 - thisBlobsEulerNumber);
> blobCentroid = blobMeasurementsB(blobNumber).Centroid; %
> Get centroid.
> labelString = sprintf('Blob #%d', blobNumber);
> text(blobCentroid(1), blobCentroid(2), labelString, 'Color', [1 .25 .
> 10], 'FontSize', 14);
> fprintf(1,'Border Blob #%d Euler Number = %d, number of Holes = %d
> \n', blobNumber, thisBlobsEulerNumber, numberOfHoles);
> end
>
> set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
> uiwait(msgbox('Check out the command window'));
|