Image patching for computing Guassian Kernel

Hi every one
I want to patch the image for Spatial Guassian kernel calculation.with a oatch size 12x12.How can I do it
image=imread('lib.jpg');
patchsize=12;
image=patch(image,patchsize);

 Réponse acceptée

Image Analyst
Image Analyst le 8 Fév 2013

0 votes

I don't know what you want to do, so I can't give an answer. (Try to explain better - upload a diagram or image if you think that would help explain)
But I do know that you should not use "image" as the name of your variable because you'll destroy the built-in function by that name.

17 commentaires

thats vey good.Actaully I am implementing the algorithm in this paper(<http://philippe.noriega.free.fr/fichiers/visapp06.pdf).I> am applying spatial gaussian kernel.I have quantize my image using kmeans algorithm in UV space.Now I want to compute spatial gaussian kernel.But I dont no the parameters they used just they showed sigma=3 but no clear informationhow did they compute dx and dy.I hink they used patching concept.can you please help me in this problem?with some piece of code.
Thanks
Image Analyst
Image Analyst le 8 Fév 2013
You can use fspecial() to create a Gaussian kernel.
fspecial('gauss',[12 12])
like that as they are using 12x12 size
how can I find 12x12 local area from image?this would be the mask
Image Analyst
Image Analyst le 8 Fév 2013
You'd probably also want to specify the sigma in the third argument.
Yes this is like that fspecial('gaussian',[12 12],3);
this is correct but as they explain that 'Pixels Sk(xk,yk) in a local area l are weigthed in terms of distance from the area centre. and dx=xk-xl
now what us xk and xl and how to compute them.as I am directly diving the size 12x12 in fspecial function.
Thanks...
Image Analyst
Image Analyst le 8 Fév 2013
Sorry - I don't have time, but it's covered in the FAQ
Good but I did not find anything related to kernel in the above links.thanks for your concern.
Image Analyst
Image Analyst le 8 Fév 2013
fspecial() creates a matrix that can be used as a kernel/template/window in sliding window operations such as blockproc(), conv2(), imfilter(), etc.
Yes so it means I am right as I did
Gsk=fspecial('gaussian',[12 12],3);
this creates my 12x12 kernel.if I am not wrong. now what is xk and xl as they are computing spatial gaussian kernel like that
G=K/2*pi*sigma*exp(-(dx*dx+dy*dy)/2.sigma*sigma); where dx=xk-xl; dy=yk-yl;
As I got 12x12 kernel now how can I compute dx and dy.
Thanks
looking for a help to solve this issue...
Image Analyst
Image Analyst le 11 Fév 2013
You don't compute them. They are the pixel distances and are already computed when fspecial() does its job.
Yeah but when fspecial() does its job It is taking the normal distance like x.^2 and y,^2 but not the distance from its centre like dx=xk-xl.Can you please clearify it?Thank you.
Image Analyst
Image Analyst le 12 Fév 2013
Let's say you're way out at pixel (106, 106) and you want to filter that pixel with a 12 by 12 window that goes from (100,100) to (111,111). The pixel at the top of the window, 6 away from the center should be a Gaussian value 6 away from the peak, not 100 away, or 106 away, or whatever else you're thinking. That would be wrong if the 12x12 window is supposed to translate across the image filtering each pixel with a 12x12 neighborhood around it. Maybe look halfway down the page here http://www.songho.ca/dsp/convolution/convolution.html for an illustration.
Yes it is clear now that fspecial is doing its job...Thank you very much.. now the problem is in color gaussian kernel here.i have a UV image which is reduced by kmeans using 40 colors and I need to compute the color gaussian kernel.I think in this case i cannot use fspecial() to do its job.becasue
du=Uk-UJ and dv=Vk-Vj
so how can I compute CGK?becasue the du.^2 and dv.^2 changes again.
For more explanation let us suppose that I have a UV image in YUV color space.and I want to compute du=Uk-UJj and dv=Dk-Dj I think that in the paper k and j are two different colors if I am not wrong.Thanks
Can any one help me how to compute color gaussian kernel?

Connectez-vous pour commenter.

Plus de réponses (1)

Thorsten
Thorsten le 11 Fév 2013
Modifié(e) : Thorsten le 11 Fév 2013
I = im2double(imread('cameraman.tif'));
Gsk = fspecial('gaussian',[12 12],3);
Idxy = I - imfilter(I, Gsk);

Catégories

En savoir plus sur Particle & Nuclear Physics dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by