Running improfile again, it appears that the target gets intensities that start at 0 and go up to 250, while the background starts at 0 and goes no higher than 50. The whiter elements are what distinguish the target. It seems to me that if you search for pixels with greater than intensity of 50 and convert them to 0, and then take pixels with intensity of between say 5 and 50 and convert them to 255, you may get a closer representation of the object (very close to binary), though I don't know yet what artifacts will be produced. How do you take pixels with specific intensities and redefine them?
Feature Detection - Part 1, image subtraction
6 次查看(过去 30 天)
显示 更早的评论
I'm a newbie to image processing, and wondered if someone could point me in the right direction. My goal is to take an image of a buck and identify its antlers and determine the Max Height and Max Width of the antlers (first in pixels and then an estimate real size from measured the distance to the target). The set of photos can be located at the following URL:
Antlers7.jpg is the image under analysis. Antlers7 subt2.jpg is a fudged photo. Our camera did not capture an image without the bucks, so I used a clone tool on a Photoshop- like program to block out the target buck. The results would have been more difficult with the other buck standing behind the target. That's why you see half a buck there to be subtracted out. I can deal with this complication later.
I = imread('Antlers7.jpg');
J = imread('Antlers7_subt2.jpg');
Ig = rgb2gray(I);
Jg = rgb2gray(J);
seline1 = strel('line',5,45);
Jgfdl = imdilate(Jg, seline1);
JgRcon = imreconstruct(Jgfdl, Jg);
Ip = Ig - JgRcon;
imshow(Ip);
This resulted in subtract2.jpg. It appeared that running a dilation on the background image (w/out buck) and a reconstruct resulted in the complete dropping of background without any noise. The background is completely black, compared to when I do a direct subtraction or use any other filtering method. The issue with this is that the antlers themselves have some zones that are completely black, so this results in loss of information.
IgCadj = imadjust(Ig,[],[],0.6);
Ip = IgCadj - JgRcon;
imshow(Ip);
When I change the gamma on the image under investigation, and then take the difference, the resulting image is Image Subtract.jpg. While some background texture appears, the animal is clearly delineated.
Running edge detection at this point does not work because of all the internal contours are highlighted as well. My eye can clearly see a boarder but don't know how to capture this with matlab. I did run improfile on the background and the foreground and there is a definite difference in range of intensities but there is overlap so this makes filtering the one from the other more difficult.
I want to generate an outline of the animal which I can then apply as a mask to the original gray scale image. Any suggestions on how to achieve this would be greatly appreciated.
8 个评论
Image Analyst
2011-11-2
pixelsToChange = (Ip>5) & (Ip < 50);
I2(pixelsToChange) = 255;
Note the single &. But I can tell you right now you'll never find antlers via simple thresholding.
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!