Display image in the form of a cylinder or a sphere?

So, let's say I have a black and white image that is read using the imread () command and stored in matrix A.

I want to output / draw this matrix. Image in the form of a cylinder. I know how to draw a cylinder in MATLAB, but I don’t know what to do if I want to put an image on a cylinder or draw an image in the shape of a cylinder. Any help would be appreciated. Thanks.

I found this site from googling. http://www.flashandmath.com/advanced/rolls/cylin.html This is exactly what I want to do, but I need to do it in MATLAB.

+4
source share
1 answer

The method is called texture mapping. This is a sample code from the surface function (R2011b):

 load clown surface(peaks,flipud(X),... 'FaceColor','texturemap',... 'EdgeColor','none',... 'CDataMapping','direct') colormap(map) view(-35,45) 

In this example, the RGB image is loaded from "peppers.png" and displayed on the cylinder:

 imgRGB = imread('peppers.png'); [imgInd,map] = rgb2ind(imgRGB,256); [imgIndRows,imgIndCols] = size(imgInd); [X,Y,Z] = cylinder(imgIndRows,imgIndCols); surface(X,Y,Z,flipud(imgInd),... 'FaceColor','texturemap',... 'EdgeColor','none',... 'CDataMapping','direct') colormap(map) view(-35,45) 

Even easier with the warp function (supplied with image processing tools) as natan :

 imgRGB = imread('peppers.png'); [imgRows,imgCols,imgPlanes] = size(imgRGB); [X,Y,Z] = cylinder(imgRows,imgCols); warp(X,Y,Z,imgRGB); 
+7
source

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


All Articles