imcrop image with hold on plot
2 views (last 30 days)
Show older comments
Does someone know how can I crop and image and a plot to obtein both the result in another figure, I tried with getframe and frame2im but it pixels the image too much.. Does someone know another option?
And I need to do it in comand line automaticalle, not using the figure option. In rect you can see the rect i would like to use in the imcrop function.
I = imread('cameraman.tif');
rect = [71.5 92.5 101 76];
figure, imshow(I);
hold on
plot(1:200,'LineWidth',2)
Thank you
2 Comments
Answers (1)
Image Analyst
on 25 Jul 2020
I = imread('cameraman.tif');
rect = [71.5 92.5 101 76];
figure
subplot(2, 1, 1);
imshow(I);
croppedImage = imcrop(I, rect);
subplot(2, 1, 2);
imshow(croppedImage);
2 Comments
Image Analyst
on 25 Jul 2020
plot() does not do cropping. Not sure why you think it does. plot() will just overlay a line/curve onto the image. Cropped images need to remain rectangular. If you want to blacken rows beyond a certain row, you can do that though
for col = 1 : 200
grayImage(col:end, col) = 0; % or whatever intensity you want.
end
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!