How to binarize this image with removing some noises with smooth surface and getting red laser line in the binary image

1 view (last 30 days)
here is my image and i want to binarize the image but i need also red line called laser in the image in the form of binary, which is important for me. i did binarize my image but i did not get beeter output. also i want to remove blue fringes in my image upto black mark.
if anyone know then try to figure this out.
I have also written my code and i attched as Three_plane.m

Answers (1)

jonas on 19 Aug 2020
I had some difficulty obtaining a solid black line by thresholding only. Since its a simple straight line, you could try something like this:
RGB = imread('image.png');
[R,G,B] = imsplit(RGB);
%threshold to get some points along line + some noise
BW = (R > 100) & (G < 100) & (B < 100);
%remove noise
BW = bwareaopen(BW,5);
%find line indices
[y,x] = find(BW == true);
%fit line
xv = 1:size(BW,2);
ft = polyfit(x,y,1)
yv = polyval(ft,xv)
imshow(BW);hold on
You could then use insertShape (CV toolbox) to "paint" the line coordinates into the image, if needed.

Community Treasure Hunt

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

Start Hunting!