Zoom and Crop Image (Matrix) - HELP!
32 views (last 30 days)
Show older comments
Rohan Nair
on 19 Feb 2015
Commented: Image Analyst
on 19 Feb 2015
Hi there, I have 2 questions that pertains to zooming and cropping of an image.
1) Zooming into an image that would make the image twice as large in both height and width and that each pixel in the matrix is replicated to become 4 pixels. Was wondering if this can be accomplished without using any loops or interpolations and the function imresize.
2) Cropping a matrix by selecting a certain area of the image and then cropping it to a certain length and height. Again, I'm wondering how this can be accomplished without using any loops or interpolations and the function imresize. Maybe by removing a certain column and row from the matrix?
Any help on how to create a function for these would be greatly appreciated. :)
0 Comments
Accepted Answer
Image Analyst
on 19 Feb 2015
1. You can use imresize(). Check out its options. See attached demo on zooming. ALso check out the 'InitialMagnification' option to imshow().
2. You can use imcrop(), or regular indexing
subImage = yourImage(row1:row2, col1:col2);
To remove a row
matrix(rowToDelete, :) = [];
2 Comments
Image Analyst
on 19 Feb 2015
imcrop just takes one array, not two. It takes [left, top, width, height]. And don't use image as the name of your variable since it's a built-in function name.
subImage = imcrop(yourImage, [x, y, width, height]);
More Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!