How do I resize an image displayed using imagesc() in a figure?
111 views (last 30 days)
Show older comments
Hi,
How do I resize the images below so they are all the one size?
function [Edges, Ihor, Iver] = edgeExtraction(Iin,B1,B2)
Iin = im2double(Iin);
% Iver = Iin .* B1;
% Ihor = Iin .* B2;
% Edges = edge(Iin);
Ihor = conv2(Iin, B2);
Iver = conv2(Iin, B1);
Edges = sqrt((Iver.^2) + (Ihor.^2));
subplot(1,4,2), imagesc(Ihor), title('Horizontal')
subplot(1,4,3), imagesc(Iver), title('Vertical')
subplot(1,4,4), imagesc(Edges), title('Edges')
end
clear all
close all
boatN = imread('boatnois.jpg');
B1 = [-1 0 1; -1 0 1; -1 0 1];
B2 = [-1 -1 -1; 0 0 0; 1 1 1];
figure(1)
subplot(1,4,1), imshow(boatN), title('Boat');
edgeExtraction(boatN, B1, B2)
0 Comments
Answers (3)
Walter Roberson
on 5 Nov 2020
imagesc() accepts properties 'XData' and 'YData', or you can pass x and y coordinates as the first two parameters to imagesc()
The x you pass should be a vector of two values, the first is the data x coordinate for the center of the lower-left pixel, and the second is the data x coordinate for the center of the upper-right pixel. Likewise for the y, and again the values are data coordinates for centers.
This does not resize the image in the sense of changing the number of pixels in the image array: this instead tells MATLAB where to draw the image, with the image being visually expanded or compacted as necessary in order to fit those data coordinates.
0 Comments
yanqi liu
on 1 Feb 2021
clc; clear all; close all;
boatN = imread('football.jpg');
B1 = [-1 0 1; -1 0 1; -1 0 1];
B2 = [-1 -1 -1; 0 0 0; 1 1 1];
figure(1)
subplot(1,4,1), imshow(boatN), title('Boat');
edgeExtraction(boatN, B1, B2)
function [Edges, Ihor, Iver] = edgeExtraction(Iin,B1,B2)
if ndims(Iin) > 2
Iin = rgb2gray(Iin);
end
Iin = im2double(Iin);
% Iver = Iin .* B1;
% Ihor = Iin .* B2;
% Edges = edge(Iin);
Ihor = conv2(Iin, B2);
Iver = conv2(Iin, B1);
Edges = sqrt((Iver.^2) + (Ihor.^2));
subplot(1,4,2), imagesc(Ihor), title('Horizontal')
axis equal
axis tight
subplot(1,4,3), imagesc(Iver), title('Vertical')
axis equal
axis tight
subplot(1,4,4), imagesc(Edges), title('Edges')
axis equal
axis tight
end
0 Comments
See Also
Categories
Find more on Subplots 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!