Image processing: Convolution & Correlation

9 visualizaciones (últimos 30 días)
Jiby
Jiby el 13 de Oct. de 2022
Respondida: V Sairam Reddy el 18 de Oct. de 2022
a. What are the pixel dimensions of ct.jpg?
b. What would the pixel dimensions of ct.jpg be after correlation or convolution with itself?
Can i know whether i am doing it right
Pixel dimensions of ct.jpg
%First set colormap and and load image
clf reset
% colormap('gray')
ct=imread('ct.jpeg')
%Pixels of the image is identified using size function
[rows, columns] = size(ct)
whos ct %verify number of pixels in the image
%Answer(a) Pixel dimensions of the image is [252*302]
%Convolution of image with itself
subplot(2,2,1), imagesc(ct);
title('Raw Image'), xlabel i, ylabel j, colorbar
subplot(2,2,2), imagesc(conv2(ct,ct));
title('Convolution Result'), xlabel i, ylabel j, colorbar
ConPixel = conv2(ct,ct)
[rowsofconv, columsofconv] = size(ConPixel)
imwrite(ConPixel,'ConPixel1.jpg','jpg')
subplot(2,2,3), imagesc(ConPixel);
title('Saved Convolution Result'), xlabel i, ylabel j, colorbar
%Answer(b) Pixel dimensions of the Convol image is [503*603]
%Correlation of image with itself
close all hidden
% colormap('gray')
subplot(2,2,1), imagesc(ct);
title('Raw Image'), xlabel i, ylabel j, colorbar
subplot(2,2,2), imagesc(xcorr2(ct,ct));
title('Correlation Result'), xlabel i, ylabel j, colorbar
CorPixel = xcorr2(ct,ct)
[rowsofcorr, columsofcorr] = size(CorPixel)
imwrite(CorPixel,'CorrPixel1.jpg','jpg')
subplot(2,2,3), imagesc(CorPixel);
title('Saved Correlation Result'), xlabel i, ylabel j, colorbar
%Answer(b) Pixel dimensions of the Correl image is [503*603]

Respuestas (1)

V Sairam Reddy
V Sairam Reddy el 18 de Oct. de 2022
Yes, you are right.
To find the pixel dimensions of "ct.jpeg" you can read it and use "size()" command.
% Read the Image.
ct_image = imread('ct.jpeg');
% Find pixel dimensions of Image.
[no_of_rows, no_of_columns] = size(ct_image);
you can find the pixel dimensions of the image after convolution or correlation with itself the same way.
% Find pixel dimensions of Image convoluted with Itself.
[no_of_rows_in_Conv_Image, no_of_columns_in_Conv_Image] = size(conv2(ct_image,ct_image));
% Find pixel dimensions of Image Correlated with Itself.
[no_of_rows_in_Corr_Image, no_of_columns_in_Corr_Image] = size(xcorr2(ct_image,ct_image));
Please refer 2D Convolution to know more about "conv2" function and 2D Cross Correlation to know more about "xcorr2" function.

Categorías

Más información sobre Orange en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by