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:
- Extracting the RGB channels in the image (Assuming RGB file format):
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.
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. You can also refer to the answers here and here for more help.
Hope this helps!