How to shear an imagesc image

조회 수: 3 (최근 30일)
Linda Toca
Linda Toca 2021년 10월 21일
답변: Pranjal Kaura 2021년 10월 26일
Hi,
I have an image, created using imagesc function from a data matrix, like so:
imagesc (myarray, [-50 0]);
which I am then trying to shear by an angle a using the following code:
a = tand(10);
T = maketform('affine', [1 0 0; a 1 0; 0 0 1] );
B = imtransform(A,T,'cubic','FillValues',orange);
orange = [255 127 0]';
figure
imshow(B)
But I keep on failing, as I guess I'm not defining A (my original image created using imagesc) correctly.
Could anyone please explain how to define it correctly so it works as an input for the imtransform function?
Thank you.
  댓글 수: 2
KSSV
KSSV 2021년 10월 21일
What error you are getting? You must specify you error along with full code.
Linda Toca
Linda Toca 2021년 10월 21일
Well, if I define A as A= imagesc (myarray, [-50 0]); and the try to to run B, i get:
Error using imtransform>check_A (line 479)
A must be a nonsparse numeric array.
Error in imtransform>parse_inputs (line 373)
args.A = check_A(varargin{1});
Error in imtransform (line 266)
args = parse_inputs(varargin{:});
So I know the problem probably lies in how I define the A

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

답변 (1개)

Pranjal Kaura
Pranjal Kaura 2021년 10월 26일
Hey Linda,
Using functions 'imtransform' and 'maketform' is not recommended because of compatibilty considerations. You can use 'imwarp' and 'affine2d' instead. Here's a code snippet addressing the changes
a = tand(10);
T = affine2d( [1 0 0; a 1 0; 0 0 1] );
B = imwarp(img,T,'cubic','FillValues',0);
Could you share more information regarding your usecase and why you need 'imagesc' function? Also the complete code, wherein you're defining 'A'.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by