Hi I have a problem when I preform the convolution original image with kernel of ones as the size of the kernel increases the output is appearing totally white Image.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Image = imread('cameraman.tif');
Image1 = double(Image);
For i=1:length(Image1)
kernel=ones(i); K=Conv2(Image1,kernel,’same’); Imshow(K)
end
0 commentaires
Réponses (1)
Walter Roberson
le 24 Fév 2024
Image = imread('cameraman.tif');
Image ranges from uint8 0 to uint8 255
Image1 = double(Image);
Image1 ranges from double 0 to double 255.
kernel=ones(i); K=Conv2(Image1,kernel,’same’);
Because of the convolution, up to i^2 locations are added together. The output could be between double 0 and double 255*(i^2) . When you add together numbers that are integral values, then you get results that are integral values, so you are going to get results that are strictly 0, 1, 2, ...
Imshow(K)
K is double 0 to (possibly) double 255*(i^2).
When imshow() is passed a double precision array, then the data is assumed to be between double 0 and double 1, and everything else is clipped to that range. But the values happen to be strictly 0, 1, 2, ... and clipping that to the range 0 to 1 will result in 0 where the data was 0, and will result in 1 everywhere else.
1 commentaire
Walter Roberson
le 24 Fév 2024
Image = imread('cameraman.tif');
Image1 = im2double(Image);
tiledlayout('flow');
for i=5:5:40
kernel = ones(i) / (i^2);
K = conv2(Image1,kernel, 'same');
nexttile();
imshow(K); title(string(i));
end
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!