java图像自定义旋转_无需自定义功能即可旋转图像

已经检查了这个SO Question,但我的问题是如何在计算后对图像进行更改显示,并且代码会更好地解释,我已经标记了哪里是困惑的行:

% code written by Zulqurnain Jutt

img1 = imread('rotme.jpg');

img = img1;

[r,m] = size(img);

promt = 'Enter Angle to Rotate an image:=:';

x = input(promt);

% making antirotate matrix

coss = cos(x);

sinn = sin(x);

antirotate = floor( [coss -sinn 0;sinn coss 0; 0 0 1] );

for i=1:r

for j=1:m

%forming point matrix

pointMat = [i-1;j-1;1];

%multiplying both matrix

mul = floor(antirotate*pointMat);

% swapping points

if mul(1)<0

mul(1) = abs(mul(1));

end

if mul(2)<0

mul(2) = abs(mul(2));

end

img( (mul(1)+1) , (mul(2)+1) ) = img(i,j); % Here Lies my problem

end

end

imshow(img);

Problem 1: "Why the output in imshow after assigning the new pixel values giving me three different images as output red , green , blue. is there any way to fix it and get one image as output?"

Problem 2: "i am converting negative coordinates to positive is this okay?"

注意:这是作业问题,我不是要隐藏它 . 但需要帮助

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值