Expand half cylinder image in MATLAB

My problem is this:

enter image description here

I have an image of a half cylinder taken from a horizontal perspective and it has square grid lines on it, so I was wondering how can I implement in MATLAB to expand this half cylinder so that all my grid cells become the same size? I know that I will lose a lot of edge resolution, and simple linear interpolation should do the trick, but I don't know how to tell MATLAB about it. I also know the geometric properties of the cylinder, radius and height. Any help is appreciated.

This is the approach I'm using, but I'm trying to find a transformation that will make the faces the same size as the inner cells.

im=imread('Capture.png');
imshow(im);
impixelinfo

r = @(x) sqrt(x(:,1).^2 + x(:,2).^2);
w = @(x) atan2(x(:,2), x(:,1));
f = @(x) [sqrt(r(x)) .* cos(w(x)), sqrt(r(x)) .* sin(w(x))];
g = @(x, unused) f(x);

tform2 = maketform('custom', 2, 2, [], g, []);
im3 = imtransform(im, tform2, 'UData', [-1 1], 'VData', [-1 1], ...
'XData', [-1 1], 'YData', [-1 1]);

figure,
imshow(im3)
+4
1

, , , . (), . ( y ) . x [-1,1], :

sin (x × π/2)

, , , .

f = @(x, unused) [sin(x (:, 1) * pi / 2), x(:, 2)]
tform2 = maketform('custom', 2, 2, [], f, []);
im3=imtransform(img, tform2, 'UData', [-1 1], 'VData', [-1 1], ...
                             'XData', [-1 1], 'YData', [-1 1]);

:

converted image

, , , . , , .

+2

Source: https://habr.com/ru/post/1610452/


All Articles