相关疑难解决方法(0)

如何使用Matlab通过最近邻插值旋转图像

我的普通代码没有插值:

im1 = imread('lena.jpg');imshow(im1);    
[m,n,p]=size(im1);
thet = rand(1);
m1=m*cos(thet)+n*sin(thet);
n1=m*sin(thet)+n*cos(thet);    

for i=1:m
    for j=1:n
       t = uint16((i-m/2)*cos(thet)-(j-n/2)*sin(thet)+m1/2);
       s = uint16((i-m/2)*sin(thet)+(j-n/2)*cos(thet)+n1/2);
       if t~=0 && s~=0           
        im2(t,s,:)=im1(i,j,:);
       end
    end
end
figure;
imshow(im2);
Run Code Online (Sandbox Code Playgroud)

这段代码会产生黑点,问题是如何进行插值?谢谢大家的任何照明.PS不要求内置函数:imrotate(im1,1/thet,'nearest');

matlab image-processing nearest-neighbor image-rotation

12
推荐指数
2
解决办法
2万
查看次数

旋转PNG,然后使用图像透明度重新保存

我在一个正在轮换的PNG上获得PNG透明度方面遇到了一些重大问题.

$filename = 'bird_up.png';
$source = imagecreatefrompng($filename) or die('Error opening file '.$filename);
imagealphablending($source, false);
imagesavealpha($source, true);
$rotation = imagerotate($source, $degrees, imageColorAllocateAlpha($source, 0, 0, 0, 127));
imagealphablending($source, false);
imagesavealpha($source, true);
header('Content-type: image/png');
imagepng($rotation);
imagedestroy($source);
imagedestroy($rotation);
Run Code Online (Sandbox Code Playgroud)

php png alpha rotation transparent

4
推荐指数
1
解决办法
5217
查看次数