I need Matlab code to draw a line on an image using two points not just between those points put on the whole image and then check if the pixels are on right of the image then make its value 0 = black else stay as is I am not proffesional at matlab and need this for a project.
Drawing a line on the image other than an annotation line has been covered in other questions on SO, see an example here: How to draw a line on an image in matlab?
If you want to go that path, I would draw the line on a black image and generate a binary mask out of it. Then apply the mask as I mention it below.
Now, if you are looking for a quick fix, here is an idea:
BW=roipoly(i1);
Then draw a polygon that encloses the left part of your image and stops at the line. You will get something like that:
Now clean it up a bit
Mask=imdilate(BW, [1 1 1 1 1; 1 1 1 1 1; 1 1 1 1 1]);
And apply the mask to the 3 layers of your RGB image:
Masked(:,:,1)=i1(:,:,1).*Mask;
Masked(:,:,2)=i1(:,:,2).*Mask;
Masked(:,:,3)=i1(:,:,3).*Mask;
imshow(Masked);
Result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.