h = vision.GeometricShearer('values' , [0 20]);
The above MATLAB command defines an object for horizontal shearing of an image. Is there a way to define the same object but for up and down shearing?
BTW, you have a small typo in your syntax. values
should be capitalized and so it's Values
. This apparently is case-sensitive.... which is a bit ridiculous, but that's the way it is.
Back to your post, you need to specify an additional flag to vision.GeometricShearer
that determines the direction of where you want to apply the shear. Specifically, you need to set the Direction
flag, and you set this to either Horizontal
or Vertical
. If you omit this, the default is Horizontal
. As such, if you want to shear the last column of your image and move it down by 20 pixels, you would do this:
h = vision.GeometricShearer('Values', [0 20], 'Direction', 'Vertical');
If you want to visualize the results, you would use step
and apply it to the image. As an example, let's load in the checkerboard
image that's part of the MATLAB system path, apply the shear, then show both of the results in the same figure:
%// Define vertical shear
h = vision.GeometricShearer('Values', [0 20], 'Direction', 'Vertical');
img = im2single(checkerboard); %// Read in image
outimg = step(h,img); %// Apply shear
%// Show both results
subplot(2,1,1), imshow(img);
title('Original image');
subplot(2,1,2), imshow(outimg);
title('Output image');
This is what I get: