フィルターのクリア

Chessboard illumination - Problems using imrotate

2 ビュー (過去 30 日間)
Joana Teixeira
Joana Teixeira 2022 年 3 月 17 日
コメント済み: Matt J 2022 年 3 月 18 日
Hello! I'm doing a chessboard with dimensions of 512x512. In my code I should apply a parameter which makes the illumination of the chessboard varies given an angle (MCangle). I used the imrotate function, but the output image shows the chessboard with black corners. I wanted that my rotate image fill my original image. I've tried to use imrotate without the 'crop' parameter, but it shows an error saying "Matrix dimensions must agree.", as expected. Can someone help me with this problem? I would be very thankful!! And sorry if my english is bad.
f1=255*ones(64);
f2=zeros(64);
R1=[f1 f2 f1 f2 f1 f2 f1 f2];
R2=[f2 f1 f2 f1 f2 f1 f2 f1];
chess=[R1;R2;R1;R2;R1;R2;R1;R2];
vl=1:512;
vc=ones(512,1);
MA=vc*vl;
MB=mat2gray(MA);
%illumination intensity
MC=MB*(0.6)+0.2;%MC=MB*(IMAX-IMIN)+IMIN;
MCangle=imrotate(MC,45,'crop');
chessintensity=chess.*MCangle;
chessI8=uint8(chessintensity);
imshow(chessI8)
  4 件のコメント
Matt J
Matt J 2022 年 3 月 17 日
Well, you need to edit your post to describe what the actual problem is. Currently, you describe a "matrix dimensions must agree" problem that doesn't exist.
Joana Teixeira
Joana Teixeira 2022 年 3 月 17 日
"I used the imrotate function, but the output image shows the chessboard with black corners. I wanted that my rotate image fill my original image." I dont want the black corners.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2022 年 3 月 17 日
編集済み: Matt J 2022 年 3 月 17 日
f1=255*ones(64);
f2=zeros(64);
R1=[f1 f2 f1 f2 f1 f2 f1 f2];
R2=[f2 f1 f2 f1 f2 f1 f2 f1];
chess=[R1;R2;R1;R2;R1;R2;R1;R2];
[x,y]=ndgrid((1:512)-mean(1:512));
MB=rescale(-x*sind(45)+y*cosd(45),0,1);
%illumination intensity
MCangle=MB*(0.6)+0.2;%MC=MB*(IMAX-IMIN)+IMIN;
chessintensity=chess.*MCangle;
chessI8=uint8(chessintensity);
imshow(chessI8)
  2 件のコメント
Joana Teixeira
Joana Teixeira 2022 年 3 月 17 日
It worked!! Thank you so much!! Can you tell what the 0 and 1 do in the rescale function?
Matt J
Matt J 2022 年 3 月 18 日
rescale(A,0,1)
will rescale A so that min(A)=0 and max(A)=1.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by