Reply by Rune Allnor April 11, 20072007-04-11
On 11 Apr, 11:44, "cedance" <aragorn1...@gmail.com> wrote:
> >On 11 Apr, 10:57, "cedance" <aragorn1...@gmail.com> 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
Reply by cedance April 11, 20072007-04-11
>On 11 Apr, 10:57, "cedance" <aragorn1...@gmail.com> 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!! regards, cedance. _____________________________________ Do you know a company who employs DSP engineers? Is it already listed at http://dsprelated.com/employers.php ?
Reply by Rune Allnor April 11, 20072007-04-11
On 11 Apr, 10:57, "cedance" <aragorn1...@gmail.com> 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
Reply by cedance April 11, 20072007-04-11
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, in case if any1 can do it. Also i have
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 the
%expression calculated in j, I just have to multiply this MTF with my
fourier %transform of the image, then take the inverse to get the
resultant image,

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

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

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

Here, the doubts i have is that, i am not quite sure as to what is the
meaning of this parameter i give inside the meshgrid. I know to some
extent that it means the amount of "defocus" or "smoothening" or "effect"
of filtering. As i increase the parameter, the image gets totally dark. Is
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 ?
Reply by Rune Allnor April 10, 20072007-04-10
On 10 Apr, 18:12, "cedance" <aragorn1...@gmail.com> wrote:
> >On 10 Apr, 17:11, "cedance" <aragorn1...@gmail.com> 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
Reply by Bo April 10, 20072007-04-10
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" <aragorn1...@gmail.com> wrote:
> >On 10 Apr, 17:11, "cedance" <aragorn1...@gmail.com> 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?
Reply by cedance April 10, 20072007-04-10
>cedance wrote: >>> On 10 Apr, 17:11, "cedance" <aragorn1...@gmail.com> 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. >&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr; >
Hi Jerry, Oh yes! I got it now. I was confusing between bessel functions and bessel filters. You got it exactly. I need a filter in shape of a bessel 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 seemed a very advanced explanation to me! :) As u might know now that my terminologies and knowledge in bessel filters/functions isnt quite that gr8. I would appreciate it if you could help me in this regard a little more. my doubt is how to get a 2D-filter of that shape? coz i am dealing with images. the way i look at it is, create a 2D filter, take the transform and multiply it in the frequency domain or convolve it in the spatial 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 ?
Reply by Jerry Avins April 10, 20072007-04-10
cedance wrote:
>> On 10 Apr, 17:11, "cedance" <aragorn1...@gmail.com> 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. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
Reply by Clay April 10, 20072007-04-10
On Apr 10, 11:05 am, "cedance" <aragorn1...@gmail.com> wrote:
> >On Apr 10, 7:33 am, "cedance" <aragorn1...@gmail.com> 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
Reply by cedance April 10, 20072007-04-10
>On 10 Apr, 17:11, "cedance" <aragorn1...@gmail.com> 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 at http://dsprelated.com/employers.php ?