I don't have very knowledge about digital image processing. I tried myself. If you help me, i will be very happy.
%tried 3
rgbImage = imread('C:\Users\metec\Desktop\608918.jpg');
[rows, columns, numberOfColorChannels] = size(rgbImage);
if rows >= 2048 && columns >= 1024 % check image sizes(m,n) m=rows n=columns
else
end
if rows * columns >= 2097152
else
end
[rows, columns, numberOfSubplots] = size(rgbImage);
if rows * columns >= 16 % check sub image sizes(p,p)
else
end
redChannel = rgbImage(:,:,1); % channel 1
subplot(3, 3, 2);
imshow(rgbImage);
fontSize = 10;
title('Original RGB Image', 'FontSize', fontSize)
subplot(3, 3, 4);
imshow(redChannel);
title('Red Channel', 'FontSize', fontSize)
This script uses the saturn.png
image which is included in MATLAB. To get you started below are the for-loop constructs. The +16
in the for-loops indicate the increment value upon each iteration of a given for-loop. I would suggest storing the sub-images in a struct
(structure).
img = imread("saturn.png");
%Grabbing channel 1 of the image%
Channel_1 = img(:,:,1);
%Resizing the test image to follow the size of the question%
Channel_1 = imresize(Channel_1,[2048 1024]);
for Row = 1: +16: 2048
for Column = 1: +16: 1024
fprintf("(%d,%d)\n",Row,Column);
%Grab sub-images here%
%Hint: Rows: (1 to 16) and Columns: (1 to 16) is the first sub-image.
end
end
subplot(1,2,1); imshow(Channel_1);
title("Original Image");
subplot(1,2,2);
title("Sub-Images");
Below is an image that indicates the divisions that need to be made. To plot where the divisions need to be made the line()
function was used.
Ran using MATLAB R2019b