How to identify a black dot in an RGB Image programmatically and then select a region in rectangle shape nearby to the black dot present in Image?

1 次查看(过去 30 天)
Hi, I want to select a particular region shown in red line with reference to point in the image(shown in black dot). Please refer the attached image.
Kindly Suggest a method to do the same using MATLAB. I need to find out that black spot in the image programmatically and then select the region based on that point present in the image. The selected region can be in the shape of rectangle.
  4 个评论
Jan
Jan 2018-1-22
@Ananthu Jayan: Again I have removed your flag. Please stop using flags to catch attraction of readers, because this is not the purpose of flags. Thanks.
I think, you do not get an answer, because this is not clear: "Can I programmatically find the position of the black spot". You did not mention, how the position of the black spot is defined. Then it is impossible to find it by an algorithm.
Explain, what you want to do. Which region do you want to select by which method?
Guillaume
Guillaume 2018-1-22
编辑:Guillaume 2018-1-22
With the test image provided, finding the location of the black dot is trivial. That begs the question: why aren't you able to do it yourself? What is the difficulty?
With regards to the region selection, what is the criteria for the size of that region? Is it a user input (again, trivial to do) or is it based on the size of the leaf? (a bit harder but not that hard) or something else?

请先登录,再进行评论。

回答(1 个)

Utkarsh Deshmukh
Utkarsh Deshmukh 2018-1-16
Try this
img = imread('img.png');
reference_point = [450, 450];
region_height = 200;
region_width = 400;
cropped_region = img(reference_point(1): reference_point(1)+region_height, reference_point(2): reference_point(2)+region_width, :);
by changing the reference point, you can change the top left coordinate. By changing the region_eidth and region_height, you can change the size of the region that you want to crop
  3 个评论
Jan
Jan 2018-1-17
This means that your image is smaller than the selected rectangle. Of course you have to adjust the values of Utkarsh Deshmukh's answer.
Ananthu Jayan
Ananthu Jayan 2018-1-18
I have attached the image above for testing. Can I programmatically find the position of the black spot in the image and then select a region accordingly.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by