- Extracting the RGB channels in the image (Assuming RGB file format):
How can I fit a line to a color joint histogram?
1 view (last 30 days)
Show older comments
Hi, in the photos like the right, I need to fit a line that approximates the yellowish color region. (Not like this green triangle, but one line that goes through the yellow region of the photo above. The file format is .fig and I have both picture on the left and right in the .fig file.
And I really don't have any idea.
Any help?
0 Comments
Answers (1)
Pranjal Kaura
on 29 Sep 2021
Hey Kyuhee,
It is my understanding that you want to identify yellow region in your image and fit a line that best approximates it's location.
Identification of the yellow region can be done using the following steps:
channel_Red = image(:, :, 1);
channel_Green = image(:, :, 2);
channel_Blue = image(:, :, 3);
2. Thresholding the required channels. Herein we need to identify yellow, thus you could try thresholding the Red and Green channels. A simple 'and' statement between the 2 binarized outputs can be taken to identify regions of yellowish tones.
BW_Red = im2binarize(channel_Red, threshold_Red);
BW_Green = im2binarize(channel_Green, threshold_Green);
3. Identifying the ROI (Region of Interest) in the binarized ouput. This will generate a rectangular bounding box around the ROI.
regionprops(BW, 'BoundingBox');
Co-ordinates and dimensions of the bounding box can then be extracted and used to generate the corner points of the required line segment (These will be the 2 opposite corner points of the rectangle). To insert the line in the image, you can use the 'InsertShape' function.
Hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!