Image processing: Convolution & Correlation
9 次查看(过去 30 天)
显示 更早的评论
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]
0 个评论
回答(1 个)
V Sairam Reddy
2022-10-18
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!