MATLAB: How to warp texture onto a part of an object (for example the cylinder)

cylinderMATLABwarp

I know there's warp command and how to warp a texture onto a cylinder
[X,Y,Z] = cylinder(imgRows,imgCols);
h = warp(X,Y,Z,imgRGB);
some time, if I only want to warp onto a part of the cylinder. I tried to use padding (white around) to make the texture bigger. But it's not in good shape.
also how to warp in perpendicular direction ? (context: I would like to create synthetic barcode printed on a cylinder shape metal can, normally, warp only gives me landscape placing on the cylinder, not portrait direction)
Thanks

Best Answer

One possible workaround will be to rotate the image using imrotate and then use warp function for wrapping around the cylinder. Or make an image of required dimensions consisting of all the elements which you want to put around the cylinder and then warp it. This will ensure it is in good shape.