How to divide image into sectors around CoG
2 次查看(过去 30 天)
显示 更早的评论
How a binary image can be divided into equal size sectors circularly around its center of gravity (CoG).
0 个评论
采纳的回答
Image Analyst
2015-12-29
Create x,y coordinates of an arc using the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_an_arc.3F.
Then pass those coordinates into poly2mask(x,y,rows,columns) to get a binary image (mask). Then multiply that by, or assign, the image to mask off everything except that sector.
Let me know if you can't figure out the attached, well commented code.
5 个评论
anastasia
2017-4-24
What if I don't want the background pixels in my pie-shaped sectors? Is it possible to automatically determine the radius for the sector taking into account different sizes of the apples?
cr = floor(size(im,1)/2);
cl = floor(size(im,2)/2);
r = min(cr, cl);
When I do this, I get quite a few background pixels in my pie-shaped sectors. My final aim is to find the color asymmetry between two sectors by determining the euclidean distance. For this, I need to minimise the no. of background pixels. How do I do that?
2. Is there any other way of using poly2mask ONLY for my apple (which is an irregularshape) Instead of dividing it into pie-shaped sectors, Can I just divide the apple into 4 parts starting from the centre and then determine the color asymmetry?
Please help
Image Analyst
2017-4-24
Find the apple mask by converting to hsv colorspace with rgb2hsv() then thresholding the S channel. The apple will have S values more than about 0.2. Now you have a mask and you can use it to blacken outside the apple, crop the image, or both.
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!