在Matlab中将大的圆形扇区映射到较小的圆形扇区

时间:2019-07-10 07:37:23

标签: matlab image-processing

我正在使用下面的代码来首先指定一个网格[X,Y],该网格代表由角度(sector_angle)和圆半径(sector_h)定义的圆形扇区,然后从RGB图像(img)中提取该扇区大小为[2 * sector_h,2 * sector_h,3]。

现在,我正在寻找一种方法,将一个较大的圆形扇区映射到一个由ector_angle_2

[X,Y] = meshgrid(0:2*sector_h-1,0:2*sector_h-1);                          
Y = flip(Y,1); X = X-sector_h; Y = Y-sector_h;                            
D = sqrt(X.^2 + Y.^2);
theta = acosd(X./D);
tmp = theta; tmp = tmp+180; tmp(Y>=0)= 0;
tmp = flip(tmp,2); theta(Y<0)=0; theta = theta+tmp;
idx = D > sector_h | theta<90-sector_angle | theta>90+sector_angle;
R = img(:,:,1);   G = img(:,:,2);   B = img(:,:,3);                    
R(idx) = 0;       G(idx) = 0;       B(idx) = 0;
img(:,:,1) = R;   img(:,:,2) = G;   img(:,:,3) = B;

0 个答案:

没有答案