필터 지우기
필터 지우기

Problem with non equal dimensions when cropping using imcrop

조회 수: 2 (최근 30일)
Aude Rapet
Aude Rapet 2017년 2월 1일
댓글: Aude Rapet 2017년 2월 2일
Hi,
I have 3 pictures, try to write a code to select an area on my a3 picture with getrect, and then crop my a1 and a2 pictures following the same selected area. I wrote this :
clear all
%Tentative de crop
a11 = imread('well5recovered.tif'); %recovered
a1 = rgb2gray(a11);
a22 = imread('well5original.tif'); %original
a2 = rgb2gray(a22);
a3 = imread ('well5 cell.tif');
imshow (a3,[]);
rg2=round (getrect); %selection zone
imgf_a1=imcrop (a1,rg2); %crop a1
figure
imshow (imgf_a1);
imgf_a2=imcrop(a2,rg2); %crop a2
figure
imshow (imgf_a2);
I dont know why I dont have the same dimension for my cropped a1 and a2. A1 is way smaller than a2 and none of them seem to be the exact same size of what I had selected on a3 with getrect.
Thank you for your help!

채택된 답변

KSSV
KSSV 2017년 2월 1일
Depending on the resolution image after cropping, the dimensions will change. If you want to have the dimensions of the cropped images same, consider resizing them in to your desired dimensions using imresize. Read about imresize.
  댓글 수: 1
Aude Rapet
Aude Rapet 2017년 2월 2일
Thanks KSSV for your answer.
All my pictures have the same dimensions, I am thinking know that maybe it is because a3 is uint16 and a1, a2 uint8
It used
a3 = im2uint8(a33);
and it seems that it is working now

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by