This example how to rotate an image with IPCV and scicv module under atoms, and from there, we will explore affine transform of an image.
Performing image rotation is straight forward with IPCV, as the function “imrotate” was implemented for the ease of use, while for scicv, we have to use OPENCV way. However, it is quite easy to write a function for scicv to match the “imrotate” as well.
Let’s look into how to rotate an image with IPCV
- First, read the image from the demo folder.
–> S = imread(fullpath(getIPCVpath() + “/images/lena.png”));
- Next, rotate the image.
–> S2 = imrotate(S,45);
That’s all! Simple right? 😊
Similar image rotation could be done in scicv,
- First, we need to initialize the module and read the image.
–> img = imread(getSampleImage(“lena.jpg”));
- Secondly, we need to find the rotational matrix for the 45 degree and use the Affine transform to rotate the image.
–> rot = getRotationMatrix2D(size(img)./2,45,1.0);
–> img_rot = warpAffine(img, rot, size(img));
- Clean the objects
More lines in scicv but you could always write an image rotation function for scicv to make it as simple as IPCV:
|function img_rot=imrotate(img, deg)
rot = getRotationMatrix2D(size(img)./2,deg,1.0);
img_rot = warpAffine(img, rot, size(img));