how to view a convolved image in matlab?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sunkara manoj
am 5 Jun. 2017
Beantwortet: Image Analyst
am 5 Jun. 2017
I am currently working on a project where I need to convolve two images grayscale images (0-255 range).I am using conv2() command but the output image matrix is having very high intensity value (292643 and above). I have tried normalizing and then convoluting but that did not work. Here is the code and the image I used.
clc;
clear all;
close all;
image=imread('du5.jpg');
figure(),imshow(image);
grayimage= rgb2gray(image);
im=grayimage;
k=imerode(im,strel('disk',1));
x=imdilate(k,strel('disk',1));
figure(),imshow(x);
k = 1000;
st=std2(x);
sigma1 = st/10;
sigma2 =sigma1*k;
h1 = fspecial('gaussian', [3,3], sigma1);
h2 = fspecial('gaussian', [9,9], sigma2);
gauss1 = imfilter(x,h1,'replicate');
gauss2 = imfilter(x,h2,'replicate');
dogImg = gauss1 - gauss2;
i=conv2(dogImg,im);
1 Kommentar
Akzeptierte Antwort
Image Analyst
am 5 Jun. 2017
The whole algorithm makes no sense. So you're getting the spatial spread of the Gaussian from the standard deviation of the intensity??? One is a distance and the other is a gray level. That is nonsense. They're different units! I see no justification for using an intensity to set a spatial parameter for finding edges.
Next, you convolve the Gaussian with the image using imfilter(). Okay, that's fine. And then you subtract them to get the dog filtered image. Okay, again that's fine. If you just wanted an edge detection image, you should be done now. But to then convolve the filtered image with the original??? What's the logic behind that? Even if you did, you'd end up with an output image 4 times the size of your original images. What are you trying to achieve?
You start off by doing a morphological opening (erosion followed by dilation, which could be done in one step by imopen()). Why? This will essentially expand small dark blobs. Why do you want to do that?
So for multiple reasons I think you need to rethink what you're trying to do.
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 5 Jun. 2017
Shape:
Subsection of the convolution, specified as one of these values:
- 'full' — Return the full 2-D convolution.
- 'same' — Return the central part of the convolution, which is the same size as A.
- 'valid' — Return only parts of the convolution that are computed without zero-padded edges.
1 Kommentar
Walter Roberson
am 5 Jun. 2017
dogImg = im2double(gauss1) - im2double(gauss2);
i = conv2(dogImg, im2double(im)); %-163 to +141
figure()
imshow(i)
figure()
i8 = uint8(i);
imshow(i8);
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!