function U = fisheye_inverse(X,T)
imageSize = T.tdata(1:2);
exponent = T.tdata(3);
origin = (imageSize+1)./2;
scale = imageSize./2;
x = (X(:,1)-origin(1))/scale(1);
y = (X(:,2)-origin(2))/scale(2);
R = sqrt(x.^2+y.^2);
theta = atan2(y,x);
cornerScale = min(abs(1./sin(theta)),abs(1./cos(theta)));
cornerScale(R < 1) = 1;
R = cornerScale.*R.^exponent;
x = scale(1).*R.*cos(theta)+origin(1);
y = scale(2).*R.*sin(theta)+origin(2);
U = [x y];
end
[X,map] = imread('logo1w.png'); %# Read the indexed image
rgbImage = ind2rgb(X,map); %# Convert to an RGB image
[r,c,d] = size(rgbImage); %# Get the image dimensions
nPad = (c-r)/2; %# The number of padding rows
rgbImage = cat(1,ones(nPad,c,3),rgbImage,ones(nPad,c,3)); %# Pad with white
options = [c c 3]; %# An array containing the columns, rows, and exponent
tf = maketform('custom',2,2,[],... %# Make the transformation structure
@fisheye_inverse,options);
newImage = imtransform(rgbImage,tf); %# Transform the image
imshow(newImage); %# Display the image
效果:
