processing image from webcam
2 次查看(过去 30 天)
显示 更早的评论
Hi, I have something to ask you.I have an image with a large rectangle and inside that rectangle there are a red circle and a green circle. And I want to locate the center of red circle with the origin-coordinate is one of the corners of rectangle. Everything has been finished with an image I draw in power point. But when I draw that image on a real paper and using a webcam to capture that image, I can't do the same things as I do with ppt image. When I convert the real image to binary, the rectangle, in some parts, is not separated with background and some areas of background don't have the same color (black or white) with others. I try to reduce threshold but it is still bad. I just want to separate the rectangle with background to "label" it and then I do anything I do with ppt image.
Here are image links
And I want to change it like this:
Can you tell me how can I do that. Sorry because my bad english.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145354/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145355/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145356/image.jpeg)
0 个评论
回答(1 个)
Saneem Ahmed
2011-4-30
I think you have applied im2bw() function on YOUR image. Try segmenting the image. it might give good results.
Other options will be converting image into other color spaces like HSV , LAB etc. If you are taking an HSV image, red and green pixel hue values will be different from blue, so keep some threshold or range to get those pixels.you can also remove light colored image parts using saturation.
use rgb2hsv() for conversion.
pic=imread('image.jpg');
hsv=rgb2hsv(pic);
bw=find(hsv<0.2 || hsv>0.8);
i haven't run the code .. but it might work...
1 个评论
Walter Roberson
2011-4-30
You would have to use | instead of || because || can only be used with scalars.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Language Support 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!