how can extract part of image
4 次查看(过去 30 天)
显示 更早的评论
fereshte
2014-6-10
hi i want to extract red region from my image.please help me.i attached it
采纳的回答
Image Analyst
2014-6-10
Do you have the original gray scale image, or just this pseudocolored image? If you unfortunately have only the pseudocolored image, see my color segmentation demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
32 个评论
Image Analyst
2014-6-10
Did you try the green image icon? Or the paperclip icon? And you'd need to give the reader for it since it's probably in some floating point format if it's temperatures. If it's only gray levels, then we can work with that via simple thresholding.
fereshte
2014-6-10
Image Analyst
2014-6-11
编辑:Image Analyst
2014-6-11
OK, so you don't have the original image. All you have is a pseudocolored image. So my answer remains as above - use color segmentation like in my demos. My "simple color detection" already does red so there's not much you need to change except the filename.
fereshte
2014-6-11
this image was original image.youre demo detection every color such as red,green and etc.but i have extract Total area under the toes that include several colors.i have just inside the area marked.
Image Analyst
2014-6-11
Find out what black is. Maybe the RGB is [0,0,0] or [23,32,18] or whatever. So extract the color bands.
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Then threshold
binaryR = redChannel > 10; % or whatever value you want/need.
binaryG = greenChannel > 10; % or whatever value you want/need.
binaryB = blueChannel > 10; % or whatever value you want/need.
Then combine
binaryImage = binaryR & binaryG & binaryB;
% Then count the number of pixels.
numPixels = sum(binaryImage(:));
fereshte
2014-6-12
I'm really confused and dont know how i get this part of image by this code. i extracted heel of this image but i dont extract upper part of footprint image by matlab code
Image Analyst
2014-6-12
What does "extract" mean to you exactly? Do you mean like crop out into a smaller separate image? Or to make measurements with regionprops()? Do you want the whole foot or just the red region? You've said both so please clarify.
fereshte
2014-6-13
编辑:fereshte
2014-6-13
ok. i extracted heel from this image to check change of colors in this region.now i want to do for part of the same rectangular area that I have highlighted in red.I want this region only like what I have to Heel.heel image attached.
I want the whole picture become black except for area that marked by red lines.
thank you
Image Analyst
2014-6-13
You mean the red "box" in the image you first posted above? How are the edges defined? It goes out far away from the red "ball of the foot" region.
fereshte
2014-6-13
yes in firs post.not important that this region is far away from the red region.i want just extract this region.my friend write me a code that extract heel of foot.i dont know how defined it.
Image Analyst
2014-6-13
Alright, I had some spare time this afternoon and downloaded your image and wrote the attached program for you (test.m in blue below the screenshot image). Can you mark the answer as accepted if this does what you asked for? Thanks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179299/image.jpeg)
Image Analyst
2014-6-13
Yes it is small. If you want to resize it for some reason, you can use imresize().
fereshte
2014-6-13
no.My goal is to obtain the total area under my big toe like the area that I've marked in red.marked region in binary image is very small area.
fereshte
2014-6-14
how change it to obtain purpose region?
measurements = regionprops(labeledImage, 'BoundingBox');
Image Analyst
2014-6-14
measurements = regionprops(labeledImage, 'BoundingBox', 'Area');
Just add in any additional measurements you want it to take.
Image Analyst
2014-6-14
Not sure why you want to do that, but you can convert a binary image into a color image (that's just black and white) by doing this:
colorImage = cat(3, binaryImage, binaryImage, binaryImage);
It will look just like the binary image but it will be color with only two colors: black and white. Kind of useless if you ask me.
fereshte
2014-6-17
is it possible in the code that outputs be colored at all stages instead of binary image?
fereshte
2014-6-17
same binary image but with main colors.i want to processing on colored extraction parts and dont need to binary image same heel image i want convert binary image to colored image
Image Analyst
2014-6-17
I gave you code above that extracts the image with the original colors. If that's not what you meant, then try to find a native English speaker to describe what you want.
fereshte
2014-6-17
youre code is true but output was binary. i enter colorImage = cat(3, binaryImage, binaryImage, binaryImage) in code but dont give me the image with the original colors.
:(
Image Analyst
2014-6-18
A binary image is just one step of my total program. If you look above at the screenshot in the above comment, you'll see an RGB subimage extracted. I gave you the cat() answer though I have no idea why you want to do that. Of course it does not give you the image with the original colors. I gave you code that did that. Why you asked for to convert the binary image into a color image is baffling to me. I don't know why you wanted to do that, and I did not do that in my code, but I gave you the code anyway because you explicitly and specifically asked for it. Again, I don't know why you asked for that or what you want to do with that, especially since I gave you the color image cropped from the original based on the binary image which I used as a mask to determine the cropping rectangle.
Image Analyst
2014-6-18
I don't know what that means. Do you mean like you want to mask the image so that it remains the full size but just zeros out (blackens) the image outside the mask?
fereshte
2014-6-18
The part where to use the mask,convert to color image. I had a change in your program and get a binary image. I want white region convert to original colors and black parts remain the same.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)