I have this code so far, the object of the assignment is to take the image \"Par
ID: 3587276 • Letter: I
Question
I have this code so far, the object of the assignment is to take the image "Parkes.png", resize it and turn it into four images in a sort of four-square type box. One is supposed to be gray, one is supposed to be gray-from-mean, and one is supposed to be edges, the last is the original image.
The issue I'm having is with concatenation, I'm not sure how to specify the dimensions for concatenation with the different filters on these images. This is the error message I'm receiving:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in test (line 17)
imshow([F1,F2])
My code is as follows:
O =imread('Parkes.png');
R = imresize(O,0.25);
%RGB
I1 = R;
%gray
I3 = rgb2gray(R);
%edge
I4 = edge(I3,'sobel');
I4 = uint8(I4.*255);
%gray from mean
I2 = mean(R,3);
I2 = uint8(I2);
F1 = cat(3,I1,I2);
F2 = cat(2,I3,I4);
imshow([F1,F2])
imshow([I1,I2,I3,I4])
Explanation / Answer
clc;
clear all;
% Read Image
O =imread('Parkes.png');
% Resize Image
R = imresize(O,0.25);
% Gray Image
I1 = rgb2gray(R);
% Gray from mean
I2 = uint8(mean(R,3));
% Edge
I3 = edge(I1,'sobel');
% RGB
I4 = R;
figure;
subplot(2,2,1), imshow(I1);
title('Gray Image');
subplot(2,2,2), imshow(I2);
title('Gray From Mean Image');
subplot(2,2,3), imshow(I3);
title('Sobel Edge Image');
subplot(2,2,4), imshow(I4);
title('Original Image');
% NOTE: In your implementation, images are created with different channels,
% like some are 3 channel image , some are 1 channel images, That's why
% concatenat was giving problem.
% Current implementation is - Devide the figure into number od parts you
% require. And then, use imshow to display any image in respective part.
% Additionally, you can add title for each part.