PDA

View Full Version : image filtering using bessel function/filters


cedance
04-10-2007, 12:33 PM
Hi,

I have been asked to design a program in Matlab which calculates the FF
of an image, then defocus the image using a Bessel filter, and reconstruc
the defocussed image. Now, I find that only analog models of Bessel filter
are available in Matlab, though i found a link to a pdf which shows value
of the coefficients upto order 10. But, how do i construct a 2D-Besse
Digital filter?

I also read the posts which say that symmetric FIR filters outwit digita
counterparts of bessel filters, but I would have to put that suggestio
yet, to get to know if i can carry on with that design. So, until then,
have to finish designing this 2D-Bessel Filter.

Please suggest me how to go about!

thanks,
cedance.



_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Clay
04-10-2007, 03:22 PM
On Apr 10, 7:33 am, "cedance" <[email protected]> wrote:
> Hi,
>
> I have been asked to design a program in Matlab which calculates the FFT
> of an image, then defocus the image using a Bessel filter, and reconstruct
> the defocussed image. Now, I find that only analog models of Bessel filters
> are available in Matlab, though i found a link to a pdf which shows values
> of the coefficients upto order 10. But, how do i construct a 2D-Bessel
> Digital filter?
>
> I also read the posts which say that symmetric FIR filters outwit digital
> counterparts of bessel filters, but I would have to put that suggestion
> yet, to get to know if i can carry on with that design. So, until then, I
> have to finish designing this 2D-Bessel Filter.
>
> Please suggest me how to go about!
>
> thanks,
> cedance.
>
Hello Cedance,

What you want is a polar form where your radial equation is a bessel
function. If you are doing something akin to diffraction through a
circular aperture, then you need J1(r) (Bessel's fuction of 1st
order). Hence for each (x,y) then compute J1(a*sqrt(x^2+y^2) where "a"
is a simple scaling factor.

IHTH,

Clay

Rune Allnor
04-10-2007, 03:23 PM
On 10 Apr, 13:33, "cedance" <[email protected]> wrote:
> Hi,
>
> I have been asked to design a program in Matlab which calculates the FFT
> of an image, then defocus the image using a Bessel filter, and reconstruct
> the defocussed image. Now, I find that only analog models of Bessel filters
> are available in Matlab, though i found a link to a pdf which shows values
> of the coefficients upto order 10. But, how do i construct a 2D-Bessel
> Digital filter?

These are two questions:

1) How to design a digital domain filter from analog prototype
2) How to make a 2D digital filter form a 1D digital prototype

The answer to the first question is generally along the lines

- Get the spec in discrete-time (DT) domain
- Transform the spec to contiouous-time (CT) domain
- Desing an analog filter which meets the CT spec
- Transform the analog prtotype from CT to DT using
e.g. the Bilinear Transform (BLT)
- Tidy up whatever details might remain.

It's a lot of work, and is a very eductaional excercise,
but might not be exactly what you need. So I'll leave the
details for now.

The second question is a bit easier.

Once you have the magnitude response of the 1D filter,
you make a circular symmetric version in 2D spectrum
domain. You could either use the filter as is in 2D
spectrum domain, or IFFT it back to 2D spatial domain
to use it as a convolution mask.

The main quirky issue with this approach is that you
need to re-sample from polar 2D spectrum coordinates to
carthesian 2D spectrum coordinates.

And yes, the spectrum phase is left unspecified.
Which may or may not be a problem.

Rune

Jerry Avins
04-10-2007, 03:43 PM
Rune Allnor wrote:
> On 10 Apr, 13:33, "cedance" <[email protected]> wrote:
>> Hi,
>>
>> I have been asked to design a program in Matlab which calculates the FFT
>> of an image, then defocus the image using a Bessel filter, and reconstruct
>> the defocussed image. Now, I find that only analog models of Bessel filters
>> are available in Matlab, though i found a link to a pdf which shows values
>> of the coefficients upto order 10. But, how do i construct a 2D-Bessel
>> Digital filter?
>
> These are two questions:
>
> 1) How to design a digital domain filter from analog prototype
> 2) How to make a 2D digital filter form a 1D digital prototype

Another question is "What does the assignment really mean?" We EEs know
Bessel filters as a particular class with particular useful properties.
The effect of diffraction on an image, as if it had been created with a
small aperture, is that of a low-pass filter whose radial response curve
has the shape of a Bessel function (J1?). That is quite another matter.
I can imagine someone familiar with the mathematics of optics but not
with the lingo of filtering could pose the problem in a misleading way.

...

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

cedance
04-10-2007, 04:05 PM
>On Apr 10, 7:33 am, "cedance" <[email protected]> wrote:
>> Hi,
>>
>> I have been asked to design a program in Matlab which calculates th
FFT
>> of an image, then defocus the image using a Bessel filter, an
reconstruct
>> the defocussed image. Now, I find that only analog models of Besse
filters
>> are available in Matlab, though i found a link to a pdf which show
values
>> of the coefficients upto order 10. But, how do i construct a 2D-Bessel
>> Digital filter?
>>
>> I also read the posts which say that symmetric FIR filters outwi
digital
>> counterparts of bessel filters, but I would have to put tha
suggestion
>> yet, to get to know if i can carry on with that design. So, until then
I
>> have to finish designing this 2D-Bessel Filter.
>>
>> Please suggest me how to go about!
>>
>> thanks,
>> cedance.
>>
>Hello Cedance,
>
>What you want is a polar form where your radial equation is a bessel
>function. If you are doing something akin to diffraction through a
>circular aperture, then you need J1(r) (Bessel's fuction of 1st
>order). Hence for each (x,y) then compute J1(a*sqrt(x^2+y^2) where "a"
>is a simple scaling factor.
>
>IHTH,
>
>Clay
>
>
>

Hi Clay,

Thanks for your reply. I understand you have a good understanding ab
this. However, i would really need a detailed explanation as to how to g
about. I have not worked with bessel functions before!!! I wouldnt say it
difficult, with Matlab. But however, can you give a detailed explanation
If any...


many thanks,
cedance.

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

cedance
04-10-2007, 04:11 PM
>Rune Allnor wrote:
>> On 10 Apr, 13:33, "cedance" <[email protected]> wrote:
>>> Hi,
>>>
>>> I have been asked to design a program in Matlab which calculates th
FFT
>>> of an image, then defocus the image using a Bessel filter, an
reconstruct
>>> the defocussed image. Now, I find that only analog models of Besse
filters
>>> are available in Matlab, though i found a link to a pdf which show
values
>>> of the coefficients upto order 10. But, how do i construct
2D-Bessel
>>> Digital filter?
>>
>> These are two questions:
>>
>> 1) How to design a digital domain filter from analog prototype
>> 2) How to make a 2D digital filter form a 1D digital prototype
>
>Another question is "What does the assignment really mean?" We EEs know
>Bessel filters as a particular class with particular useful properties.
>The effect of diffraction on an image, as if it had been created with a
>small aperture, is that of a low-pass filter whose radial response curv

>has the shape of a Bessel function (J1?). That is quite another matter.
>I can imagine someone familiar with the mathematics of optics but not
>with the lingo of filtering could pose the problem in a misleading way.
>
> ...
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
>

Hi Jerry,

Actually, this is in fact a project related to Optics. The bessel functio
i am to use is for defocussing the image as i had previously mentioned
Pardon me if i have confused with my own thoughts, as to how to go about
I think the previous reply i got is how i should go about, but still
detailed explanation or a link would be highly useful.

thanks a lot,
cedance.

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Rune Allnor
04-10-2007, 04:56 PM
On 10 Apr, 17:11, "cedance" <[email protected]> wrote:

> >I can imagine someone familiar with the mathematics of optics but not
> >with the lingo of filtering could pose the problem in a misleading way.
....
> Actually, this is in fact a project related to Optics.

It seems you are trying to simulate some physical effects of
some optics system, then.

If this is indeed the case, you have come to the wrong forum.
You would probably need to consult people who know modeling
of optical systems, to achive exactly the effect you want.
The term "bessel filter" makes sense both in DSP and optics,
but mean different things.

You might want to get back to your boss or supervisor and
explain ti him or her that you have found the term "Bessel
filter" in the context of DSP, and is confused as to whether
this is what you want.

You will then get directions for exactly where to look for
material relevant to your application.

Rune

Clay
04-10-2007, 05:12 PM
On Apr 10, 11:05 am, "cedance" <[email protected]> wrote:
> >On Apr 10, 7:33 am, "cedance" <[email protected]> wrote:
> >> Hi,
>
> >> I have been asked to design a program in Matlab which calculates the
> FFT
> >> of an image, then defocus the image using a Bessel filter, and
> reconstruct
> >> the defocussed image. Now, I find that only analog models of Bessel
> filters
> >> are available in Matlab, though i found a link to a pdf which shows
> values
> >> of the coefficients upto order 10. But, how do i construct a 2D-Bessel
> >> Digital filter?
>
> >> I also read the posts which say that symmetric FIR filters outwit
> digital
> >> counterparts of bessel filters, but I would have to put that
> suggestion
> >> yet, to get to know if i can carry on with that design. So, until then,
> I
> >> have to finish designing this 2D-Bessel Filter.
>
> >> Please suggest me how to go about!
>
> >> thanks,
> >> cedance.
>
> >Hello Cedance,
>
> >What you want is a polar form where your radial equation is a bessel
> >function. If you are doing something akin to diffraction through a
> >circular aperture, then you need J1(r) (Bessel's fuction of 1st
> >order). Hence for each (x,y) then compute J1(a*sqrt(x^2+y^2) where "a"
> >is a simple scaling factor.
>
> >IHTH,
>
> >Clay
>
> Hi Clay,
>
> Thanks for your reply. I understand you have a good understanding abt
> this. However, i would really need a detailed explanation as to how to go
> about. I have not worked with bessel functions before!!! I wouldnt say its
> difficult, with Matlab. But however, can you give a detailed explanation!
> If any...
>
> many thanks,
> cedance.
>

Hello Cedance,

The form you need for the radial function is J1(a*r)/(a*r) (I left
that last part (denominator term) out of my earlier response)

Basically what is going on is your blurring is the computing of a
blurred pixel as the average of all pixels in a circular regoin
surrounding your pixel. So what is the fourier transform of a circular
aperture? It is the bessel filter with H(r,theta) = J1(ar)/(ar). An
ideal lowpass filter in this case would put the 1st zero of J1()
(which is at 1.21966*pi) on top of the neighboring pixel. The "a" is
the scaling (blurring) factor in this case.

So by blurring the picture by using an FFT, you are instead of
convolving the original image with circular apertures, you are
converting over to spatial frequencies and multiplying the picture
with the bessel filter and then converting back. To get an idea of
what your bessel filter will look like, try looking up Airy discs.

IHTH,

Clay

cedance
04-10-2007, 05:12 PM
>On 10 Apr, 17:11, "cedance" <[email protected]> wrote:
>
>> >I can imagine someone familiar with the mathematics of optics but not
>> >with the lingo of filtering could pose the problem in a misleadin
way.
>...
>> Actually, this is in fact a project related to Optics.
>
>It seems you are trying to simulate some physical effects of
>some optics system, then.
>
>If this is indeed the case, you have come to the wrong forum.
>You would probably need to consult people who know modeling
>of optical systems, to achive exactly the effect you want.
>The term "bessel filter" makes sense both in DSP and optics,
>but mean different things.
>
>You might want to get back to your boss or supervisor and
>explain ti him or her that you have found the term "Bessel
>filter" in the context of DSP, and is confused as to whether
>this is what you want.
>
>You will then get directions for exactly where to look for
>material relevant to your application.
>
>Rune
>
>

Hi Rune,

It is difficult to explain on what regard, the project is. Its somethin
related to the human eye, its functioning/behavior to "DEFOCUS". Its wel
known that bessel filter is a smoothening filter used in measuring th
amount or depth of defocus. I think you ppl might be aware of besse
filters used to correct teh images where image is blurred as a result o
defocus.

In this regard alone, i need the help, and i fail to see how it i
irrelevant to filtering. I need to apply the filter to defocus the image
My professor has told me to take the fft of the image and then multipl
with the filter and reconstruct the image, the IFFT namely. So, I think
have come to the right forum???

Also, I think the reply Clay gave was more or less the idea i am wanting
I am waiting for his reply. Anyways, If you still feel its irrelevant
then I would just wait for the reply from Clay, if any and then decide.

thanks a lot,
cedance.

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Jerry Avins
04-10-2007, 05:37 PM
cedance wrote:
>> On 10 Apr, 17:11, "cedance" <[email protected]> wrote:
>>
>>>> I can imagine someone familiar with the mathematics of optics but not
>>>> with the lingo of filtering could pose the problem in a misleading
> way.
>> ...
>>> Actually, this is in fact a project related to Optics.
>> It seems you are trying to simulate some physical effects of
>> some optics system, then.
>>
>> If this is indeed the case, you have come to the wrong forum.
>> You would probably need to consult people who know modeling
>> of optical systems, to achive exactly the effect you want.
>> The term "bessel filter" makes sense both in DSP and optics,
>> but mean different things.
>>
>> You might want to get back to your boss or supervisor and
>> explain ti him or her that you have found the term "Bessel
>> filter" in the context of DSP, and is confused as to whether
>> this is what you want.
>>
>> You will then get directions for exactly where to look for
>> material relevant to your application.
>>
>> Rune
>>
>>
>
> Hi Rune,
>
> It is difficult to explain on what regard, the project is. Its something
> related to the human eye, its functioning/behavior to "DEFOCUS". Its well
> known that bessel filter is a smoothening filter used in measuring the
> amount or depth of defocus. I think you ppl might be aware of bessel
> filters used to correct teh images where image is blurred as a result of
> defocus.
>
> In this regard alone, i need the help, and i fail to see how it is
> irrelevant to filtering. I need to apply the filter to defocus the image.
> My professor has told me to take the fft of the image and then multiply
> with the filter and reconstruct the image, the IFFT namely. So, I think I
> have come to the right forum???
>
> Also, I think the reply Clay gave was more or less the idea i am wanting.
> I am waiting for his reply. Anyways, If you still feel its irrelevant,
> then I would just wait for the reply from Clay, if any and then decide.
>
> thanks a lot,
> cedance.

Clay has set you on the right path. It is now clear that you want a
filter with the shape of a Bessel function. In signal processing, a
Bessel filter has maximally flat delay vs. frequency. It gets its name
from the use of Bessel functions to compute the component values. It's
not at all the same thing. http://en.wikipedia.org/wiki/Bessel_filter

I am puzzled by what I see as a conflict between the requirement --
Bessel shape indicating a diffraction process -- and your using the term
"defocus". The two kinds of blurring are only superficially the same.

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

cedance
04-10-2007, 06:03 PM
>cedance wrote:
>>> On 10 Apr, 17:11, "cedance" <[email protected]> wrote:
>>>
>>>>> I can imagine someone familiar with the mathematics of optics bu
not
>>>>> with the lingo of filtering could pose the problem in a misleading
>> way.
>>> ...
>>>> Actually, this is in fact a project related to Optics.
>>> It seems you are trying to simulate some physical effects of
>>> some optics system, then.
>>>
>>> If this is indeed the case, you have come to the wrong forum.
>>> You would probably need to consult people who know modeling
>>> of optical systems, to achive exactly the effect you want.
>>> The term "bessel filter" makes sense both in DSP and optics,
>>> but mean different things.
>>>
>>> You might want to get back to your boss or supervisor and
>>> explain ti him or her that you have found the term "Bessel
>>> filter" in the context of DSP, and is confused as to whether
>>> this is what you want.
>>>
>>> You will then get directions for exactly where to look for
>>> material relevant to your application.
>>>
>>> Rune
>>>
>>>
>>
>> Hi Rune,
>>
>> It is difficult to explain on what regard, the project is. It
something
>> related to the human eye, its functioning/behavior to "DEFOCUS". It
well
>> known that bessel filter is a smoothening filter used in measuring the
>> amount or depth of defocus. I think you ppl might be aware of bessel
>> filters used to correct teh images where image is blurred as a resul
of
>> defocus.
>>
>> In this regard alone, i need the help, and i fail to see how it is
>> irrelevant to filtering. I need to apply the filter to defocus th
image.
>> My professor has told me to take the fft of the image and the
multiply
>> with the filter and reconstruct the image, the IFFT namely. So, I thin
I
>> have come to the right forum???
>>
>> Also, I think the reply Clay gave was more or less the idea i a
wanting.
>> I am waiting for his reply. Anyways, If you still feel its irrelevant,
>> then I would just wait for the reply from Clay, if any and the
decide.
>>
>> thanks a lot,
>> cedance.
>
>Clay has set you on the right path. It is now clear that you want a
>filter with the shape of a Bessel function. In signal processing, a
>Bessel filter has maximally flat delay vs. frequency. It gets its name
>from the use of Bessel functions to compute the component values. It's
>not at all the same thing. http://en.wikipedia.org/wiki/Bessel_filter
>
>I am puzzled by what I see as a conflict between the requirement --
>Bessel shape indicating a diffraction process -- and your using the ter

>"defocus". The two kinds of blurring are only superficially the same.
>
>Jerry
>--
>Engineering is the art of making what you want from things you can get.
>¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
>

Hi Jerry,

Oh yes! I got it now. I was confusing between bessel functions and besse
filters. You got it exactly. I need a filter in shape of a besse
function. And what Clay has explained, if its self explanatory to you
could u give me more insight into it as to how to go about? Coz, it seeme
a very advanced explanation to me! :) As u might know now that m
terminologies and knowledge in bessel filters/functions isnt quite tha
gr8. I would appreciate it if you could help me in this regard a littl
more.

my doubt is how to get a 2D-filter of that shape? coz i am dealing wit
images. the way i look at it is, create a 2D filter, take the transfor
and multiply it in the frequency domain or convolve it in the spatia
domain. so how do i go about it?


thanks a lot to every1 again! this forum rocks!
cedance.

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Bo
04-10-2007, 06:13 PM
I think there is something problematic here. The defocus filtering is
not exactly the Airy function (J1(r)/r)^2. This airy function appears
as the bluring PSF of a lens system when it is IN FOCUS. Suppose that
your lens has a focus f, and now your image is taken at the distance z
> f. Then the defocus pupil function is the disk indicating function
multiplied by a complex factor exp(ikr^2/2*(1/f-1/z)), where k is the
wavenumber and r is the radial coordinate. To get the defocus PSF, you
need to take the fourier transform of the defocus pupil function and
take a module-square. This gives you the image-domain filter. Of
course, there is an equivalent way to proceed all these in the Fourier
domain.

On 10 avr, 18:12, "cedance" <[email protected]> wrote:
> >On 10 Apr, 17:11, "cedance" <[email protected]> wrote:
>
> >> >I can imagine someone familiar with the mathematics of optics but not
> >> >with the lingo of filtering could pose the problem in a misleading
> way.
> >...
> >> Actually, this is in fact a project related to Optics.
>
> >It seems you are trying to simulate some physical effects of
> >some optics system, then.
>
> >If this is indeed the case, you have come to the wrong forum.
> >You would probably need to consult people who know modeling
> >of optical systems, to achive exactly the effect you want.
> >The term "bessel filter" makes sense both in DSP and optics,
> >but mean different things.
>
> >You might want to get back to your boss or supervisor and
> >explain ti him or her that you have found the term "Bessel
> >filter" in the context of DSP, and is confused as to whether
> >this is what you want.
>
> >You will then get directions for exactly where to look for
> >material relevant to your application.
>
> >Rune
>
> Hi Rune,
>
> It is difficult to explain on what regard, the project is. Its something
> related to the human eye, its functioning/behavior to "DEFOCUS". Its well
> known that bessel filter is a smoothening filter used in measuring the
> amount or depth of defocus. I think you ppl might be aware of bessel
> filters used to correct teh images where image is blurred as a result of
> defocus.
>
> In this regard alone, i need the help, and i fail to see how it is
> irrelevant to filtering. I need to apply the filter to defocus the image.
> My professor has told me to take the fft of the image and then multiply
> with the filter and reconstruct the image, the IFFT namely. So, I think I
> have come to the right forum???
>
> Also, I think the reply Clay gave was more or less the idea i am wanting.
> I am waiting for his reply. Anyways, If you still feel its irrelevant,
> then I would just wait for the reply from Clay, if any and then decide.
>
> thanks a lot,
> cedance.
>
> _____________________________________
> Do you know a company who employs DSP engineers?
> Is it already listed athttp://dsprelated.com/employers.php?

Rune Allnor
04-10-2007, 06:31 PM
On 10 Apr, 18:12, "cedance" <[email protected]> wrote:
> >On 10 Apr, 17:11, "cedance" <[email protected]> wrote:
>
> >> >I can imagine someone familiar with the mathematics of optics but not
> >> >with the lingo of filtering could pose the problem in a misleading
> way.
> >...
> >> Actually, this is in fact a project related to Optics.
>
> >It seems you are trying to simulate some physical effects of
> >some optics system, then.
>
> >If this is indeed the case, you have come to the wrong forum.
> >You would probably need to consult people who know modeling
> >of optical systems, to achive exactly the effect you want.
> >The term "bessel filter" makes sense both in DSP and optics,
> >but mean different things.
>
> >You might want to get back to your boss or supervisor and
> >explain ti him or her that you have found the term "Bessel
> >filter" in the context of DSP, and is confused as to whether
> >this is what you want.
>
> >You will then get directions for exactly where to look for
> >material relevant to your application.
>
> >Rune
>
> Hi Rune,
>
> It is difficult to explain on what regard, the project is. Its something
> related to the human eye, its functioning/behavior to "DEFOCUS". Its well
> known that bessel filter is a smoothening filter used in measuring the
> amount or depth of defocus. I think you ppl might be aware of bessel
> filters used to correct teh images where image is blurred as a result of
> defocus.
>
> In this regard alone, i need the help, and i fail to see how it is
> irrelevant to filtering.

This is most certanly a filtering question. I am a bit worried
that your boss has something very specific in mind. I used to
work with acoustic data modeling. Most of what we did to manipulate
the data could be regarded as "filtering." However, the operations
were, more often than not, based on very specific physical effects
which were very carefully modeled.

> I need to apply the filter to defocus the image.
> My professor has told me to take the fft of the image and then multiply
> with the filter and reconstruct the image, the IFFT namely. So, I think I
> have come to the right forum???

As far as *applying* the filter, yes. Maybe not with respect to
*designing* the filter.

Rune

cedance
04-11-2007, 09:57 AM
Hi guys,

With a little bit of research on the internet and with the idea you guy
gave, I managed to write a simple script in matlab, i would like to verif
the integrity of the script here, in case if any1 can do it. Also i hav
some doubts reg. this, I have posed them below the script.

[x,y] = meshgrid(-5:10/255:5); %creates the mesh grid size 256*256
r = sqrt(x.^2 + y.^2); %create the matrix r
j = besselj(1,r); % now the bessel function of first kind
mesh(x,y,j); %shows the 2D bessel function.

%having created the modulation transfer function, which is indeed th
%expression calculated in j, I just have to multiply this MTF with m
fourier %transform of the image, then take the inverse to get th
resultant image,

a = rgb2gray(imread('sample.jpg')); %size 256*256 and only gray scal
images as of now.

b = ifft2(fft2(a) .* j); %multiply the image with the MTF and take th
iFFT

imshow(uint8(b)); %display the image

Here, the doubts i have is that, i am not quite sure as to what is th
meaning of this parameter i give inside the meshgrid. I know to som
extent that it means the amount of "defocus" or "smoothening" or "effect
of filtering. As i increase the parameter, the image gets totally dark. I
it how it should be. In general, can any1 point me the flaws in this code
if any, or is it totally wrong?


thanks a lot.
cedance.


_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Rune Allnor
04-11-2007, 10:37 AM
On 11 Apr, 10:57, "cedance" <[email protected]> wrote:
> Hi guys,
>
> With a little bit of research on the internet and with the idea you guys
> gave, I managed to write a simple script in matlab, i would like to verify
> the integrity of the script here,

As far as both matlab and 2D filtering goes, this seems
to be OK. I don't know the details of your application,
so I don't have any opinions as to whether this script
does the job what your boss wanted your program to do.

Check with your boss.

Remember, while your boss or professor might seem a bit
distanced or maybe even appear daunting, he or she *does*
have an interest in you and your work. The worst students,
as far as I am concerned, are those who just fumble around
in the dark without asking questions. No one knows what
they are doing, or even what the ought to be doing.
If somebody comes up and asks "I checked out the terms
you mentioned, but I can't quite make sense of them"
they show some initiaive and demonstrate interest for
the job. Provided they *did* check out the terms, of
course...

As I said before: You are working with a different
application than what is usually discussed here. The
terminology *seems* similar, but the terms *might* have
vastly different meanings to you, as an optician, and
to me as a DSP practitioner. You need to be aware of this,
and you need to check with your boss that you really are
on the right track before you commit to anything you have
learned here, either by submitting a program or a thesis.

Rune

cedance
04-11-2007, 10:44 AM
>On 11 Apr, 10:57, "cedance" <[email protected]> wrote:
>> Hi guys,
>>
>> With a little bit of research on the internet and with the idea yo
guys
>> gave, I managed to write a simple script in matlab, i would like t
verify
>> the integrity of the script here,
>
>As far as both matlab and 2D filtering goes, this seems
>to be OK. I don't know the details of your application,
>so I don't have any opinions as to whether this script
>does the job what your boss wanted your program to do.
>
>Check with your boss.
>
>Remember, while your boss or professor might seem a bit
>distanced or maybe even appear daunting, he or she *does*
>have an interest in you and your work. The worst students,
>as far as I am concerned, are those who just fumble around
>in the dark without asking questions. No one knows what
>they are doing, or even what the ought to be doing.
>If somebody comes up and asks "I checked out the terms
>you mentioned, but I can't quite make sense of them"
>they show some initiaive and demonstrate interest for
>the job. Provided they *did* check out the terms, of
>course...
>
>As I said before: You are working with a different
>application than what is usually discussed here. The
>terminology *seems* similar, but the terms *might* have
>vastly different meanings to you, as an optician, and
>to me as a DSP practitioner. You need to be aware of this,
>and you need to check with your boss that you really are
>on the right track before you commit to anything you have
>learned here, either by submitting a program or a thesis.
>
>Rune
>
>

Hey Rune,

Thanks a lot for stressing this point. I would clarify this with my Bos
and make sure I am on the right track. Very kind of you for pointing ou
timely again!!

regards,
cedance.

_____________________________________
Do you know a company who employs DSP engineers?
Is it already listed at http://dsprelated.com/employers.php ?

Rune Allnor
04-11-2007, 12:07 PM
On 11 Apr, 11:44, "cedance" <[email protected]> wrote:
> >On 11 Apr, 10:57, "cedance" <[email protected]> wrote:
> >> Hi guys,
>
> >> With a little bit of research on the internet and with the idea you
> guys
> >> gave, I managed to write a simple script in matlab, i would like to
> verify
> >> the integrity of the script here,
>
> >As far as both matlab and 2D filtering goes, this seems
> >to be OK. I don't know the details of your application,
> >so I don't have any opinions as to whether this script
> >does the job what your boss wanted your program to do.
>
> >Check with your boss.
>
> >Remember, while your boss or professor might seem a bit
> >distanced or maybe even appear daunting, he or she *does*
> >have an interest in you and your work. The worst students,
> >as far as I am concerned, are those who just fumble around
> >in the dark without asking questions. No one knows what
> >they are doing, or even what the ought to be doing.
> >If somebody comes up and asks "I checked out the terms
> >you mentioned, but I can't quite make sense of them"
> >they show some initiaive and demonstrate interest for
> >the job. Provided they *did* check out the terms, of
> >course...
>
> >As I said before: You are working with a different
> >application than what is usually discussed here. The
> >terminology *seems* similar, but the terms *might* have
> >vastly different meanings to you, as an optician, and
> >to me as a DSP practitioner. You need to be aware of this,
> >and you need to check with your boss that you really are
> >on the right track before you commit to anything you have
> >learned here, either by submitting a program or a thesis.
>
> >Rune
>
> Hey Rune,
>
> Thanks a lot for stressing this point. I would clarify this with my Boss
> and make sure I am on the right track. Very kind of you for pointing out
> timely again!!

As you said in an eariler post: A "Bessel filter" and
a "Bessel function" are two different things. It took
a while to sort tat out here, a professor might have
seen that confusion before and helped you out. Either
way the prof would get an impression of you and how
you work.

I could tell numerous "war stories" about confusion over
the same terms being used in *slightly* different situations
and in *slightly* different ways (the most recent one,
over stock market data, being batteled out here last week...).

The first time I was made aware of the issue, was when
I took my first course on physical acoustics. The first
part of the course was about sonars, expressing the
wave equation in terms of pressure:

d^2p/dx^2 = -1/c^2 d^2p/dt^2 [1]

The signs may be wrong, but leave that for now. The second
part of the course was about seismics. In seismics,
the wave equation is expressed in terms of *tension*, s:

d^2s/dx^2 = +1/c^2 d^2s/dt^2 [2]

The difference is subtle: Positive pressure tends to
shorten a rod, while positive tension tends to lengthen
it. (BTW, did you note the different signs on the right
hand sides of [1] and [2]?)

One of my classmates worked on a term project involving
some manipulations of the *seismics* wave equation.
He hadn't noted the difference in sign, and struggeled
badly to reach his goals for the project. A couple of
days -- literally -- before hus project deadline, he
found that detail. In 48 hours he duplicated 4 months
worth of work and wrote a totally new report.

He made it, but it is not an effort I would like
to witness again, if I can avoid it.

While the problem was caused by a detail in the wave
equation, it wouldn't have helped the least to ask
an expert on, say, electromagnetic wave propagation
to find the error.

Which it is so crucially important to consult people
who know the scope of the problem, when you search
for solutions.

Rune