imcrop image with hold on plot

조회 수: 10 (최근 30일)
Alejandro Fernández
Alejandro Fernández 2020년 7월 25일
댓글: Image Analyst 2020년 7월 25일
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
KSSV
KSSV 2020년 7월 25일
You ave not cropped your image. Question is not clear.
Alejandro Fernández
Alejandro Fernández 2020년 7월 25일
Sorry, I thought the question was clear, let me try to explain it to you with an example. Imagine I have a function that returns a figure containing the representation of an image and with hold on some data from the plot function. What I need is to cut out that figure which is extracted from the previous function

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2020년 7월 25일
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
Alejandro Fernández
Alejandro Fernández 2020년 7월 25일
That's not what i'm asking... i need to crop it with the :
plot(1:200,'LineWidth',2)
Image Analyst
Image Analyst 2020년 7월 25일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by