Mapping image into cylinder

Mapping image into cylinder or sphere shape:

  1. Load image (so now it is in one big matrix)
  2. Use whole image for texture mapping onto one surface
  3. Use part of the image for texture mapping onto another surface

result:
Mappingimage

imgRGB = imread('peppers.png');
[imgRows,imgCols,imgPlanes] = size(imgRGB);
for p=1:imgPlanes
imgRGBFlipped(:,:,p) = flipud( imgRGB(:,:,p) );
end
[CX,CY,CZ] = cylinder(imgRows,imgCols);

% Now select a part of image
subimage = imgRGB( 1:200, 1:400, :); % rows 1 to 200 columns 1 to 400
for p=1:imgPlanes
subimageFlipped(:,:,p) = flipud( subimage(:,:,p) );
end
[SX,SY,SZ] = sphere(200);

figure;
subplot(2,2,1); imshow(imgRGB); title('Full image')
subplot(2,2,2); warp(CX,CY,CZ,imgRGBFlipped); title('Full image on cylinder')
subplot(2,2,3); imshow(subimage); title('Part of image')
subplot(2,2,4); warp(SX,SY,SZ,subimageFlipped); title('Part of image on sphere')

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.