Prev: how to convert all frames of particular video into corresponding images?
Next: How does interpolation work in interp2?
From: Anna on 4 Aug 2010 07:46 Dear ImageAnalysist, Thanks again for your help. I have been trying many different things but am still having some trouble. I have followed your code and thresholded the image. This then results in 3 objects. I have then tried the following to leave me with just one of the objects (the smallest one): stats2=regionprops(binaryImage,'Area'); stats=regionprops(binaryImage,'BoundingBox'); for i = 1:size(stats); keeperImage = find(([stats2.Area] <= 3) & ([stats(i).BoundingBox(3)] <=2) & ([stats(i).BoundingBox(4)] <=4)); FibreBreaksImage = ismember(binaryImage, keeperImage); maskedImageBreaks = originalImage; % Simply a copy at first. maskedImageBreaks(~FibreBreaksImage) = 0; % Set all non-keeper pixels to zero. subplot(3, 3, 5); imshow(maskedImageBreaks,[]); end; This however results in the image see here ... http://drop.io/wwvnehs/asset/results-jpg where the object in question is not selected. Any help you could give would be great. Kind Regards Anna
From: ImageAnalyst on 4 Aug 2010 09:40 Anna: What happens if you use stats2(i).Area By the way, you should be able to just do stats=regionprops(binaryImage,'BoundingBox', 'Area'); and get all the measurements in one structure instead of two structures.
From: Anna on 4 Aug 2010 11:36 I did as you suggested but with still the same results. The areas of the three 'blobs' are 7,3 and 9. If I change the settings to detect all 'blobs' (i.e. [stats(i).Area] <= 9) & ([stats(i).BoundingBox(3)] <=10) & ([stats(i).BoundingBox(4)] <=10)) then all three 'blobs' are detected, however the resultant image is a grayscale not binary. If I then reduce the area to <=8m, the other two blobs should be detected but they are not. Thanks, Anna
From: ImageAnalyst on 4 Aug 2010 11:52 Anna: If you ask for all blobs with area less than or equal to 9, then yes, you'll get blobs with areas of 3, 7, and 9, just as you requested. Using ismember will give you a logical (binary) image if you pass in a labeled (gray scale) image and a list of "keeper indexes", so I'm not sure how/why you're getting a gray scale image out of it. Maybe you can post your full code. Actually I'm not sure why you're even using a loop for this part. No for loop is necessary. Look at my demo code - I didn't use a loop to extract out the objects of interest. I just did this: % Now let's get the nickels (the larger coin type) keeperIndexes = find(allBlobAreas > 2000); % Take the larger objects. % Note how we use ismember to select the blobs that meet our criteria. nickelBinaryImage = ismember(labeledImage, keeperIndexes); maskedImageNickel = originalImage; % Simply a copy at first. maskedImageNickel(~nickelBinaryImage) = 0; % Set all non-nickel pixels to zero. -ImageAnalyst
From: Anna on 4 Aug 2010 12:12 I have used a loop as I thought that you cant write: stats.BoundingBox(3), you need stats(1).BoundingBox(3), as you need a field after stats? Shall I add my code to the file exchange for you to look at? Thanks again, Anna
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: how to convert all frames of particular video into corresponding images? Next: How does interpolation work in interp2? |