2
$\begingroup$

I would like to combine two images A and B in the following way:

1) I want to take a Fourier transform of both of them

2) For image A I want to apply a weighted filter, which gives more emphasis for low frequencies

3) For image B I want to apply a weighted filter, which gives more emphasis for high frequencies

4) I want to combine these frequencies and take the inverse Fourier transform

Can someone give me any guidelines where I should start (which functions etc.) to do this in Matlab? =) I'm kinda learning about Fourier transform and I want to play around with images. I was hoping if someone could give an example of code how this could be done etc.

Please note that I'm new at this stuff and I'm not very familiar with all the terminology yet. I'm an amateur trying to learn about Fourier transform by doing an experiment with it :)

Thank you for any help! =)

P.S. I would appreciate if someone could give me a minimal code snippet showing me what I need to do =)

$\endgroup$
  • 2
    $\begingroup$ By combine do you mean add? In which case: do the addition of the two images. (Or of the two fourier transformed images before you do the inverse transform. It's the same thing since the fourier transform is linear.) $\endgroup$ – Wandering Logic Jun 18 '13 at 12:15
  • $\begingroup$ @Wandering Logic Yes I do mean adding. Could you give me a minimal example? Doing the transform and adding and inverse transform :) Thank you for your answer! $\endgroup$ – jjepsuomi Jun 18 '13 at 12:16
  • 3
    $\begingroup$ mathworks.com/help/images/ref/imadd.html $\endgroup$ – Wandering Logic Jun 18 '13 at 12:16
  • $\begingroup$ Duplicate (same user): stackoverflow.com/questions/17167689/… $\endgroup$ – Paul R Jun 18 '13 at 15:10
3
$\begingroup$

The easiest way doing so would be Laplacian Pyramid.

Yet, it can be done just by using simple Addition operator.
Just add the High Frequency of one image to the Low Frequency of the other.
Keep in mind few things:

  1. Dimensions must be the same.
    Otherwise, interpolate to the same dimensions.
  2. It is better to use HPF which is built from the same LPF used.
    To the least, they must have the same Cut Off Frequency.
  3. Use floating point arithmetic for this procedure.
$\endgroup$
2
$\begingroup$

You could weigh together the images Discrete Wavelet Transforms (DWT), where one image has declining weights with increasing scale and vice versa. The DWT filters are designed to have the perfect reconstruction property so you don't need to worry about cut-off frequencies. This algorithm could have complexity $\mathcal{O}(n)$ where $n$ is the number of pixels.


EDIT clarification: With $\mathcal{O}(n)$ I mean that the numbers of computations required by the algorithm will be proportional to the number of pixels $n$. So it is a measure of computational complexity. Other algorithms can have for instance $\mathcal{O}(n^2)$ if the computational complexity is proportional to the square of the number of data points. In this sense $\mathcal{O}(n)$ is very low complexity, it is far more common with higher complexities such as $\mathcal{O}(n\log(n))$ or $\mathcal{O}(n^2)$ or $\mathcal{O}(n^3)$

$\endgroup$
  • $\begingroup$ Your $O(n)$ notation is quite strange... as "n" will be $n=NN = N^2$ for a square image. And it represents a qudratic performance $O(N^2)$ instead of the linear $O(n)$ as in your notation... $\endgroup$ – Fat32 Jan 7 '16 at 22:20
  • $\begingroup$ I consider $n$ to be the total number of pixels, not the width or height of the image. $\endgroup$ – mathreadler Jan 7 '16 at 22:26
  • $\begingroup$ Is it the standard notation for the computational complexity of multidimensional data? Because it is easier to compare "dimensions" of such data rather than total number of points. As is done for example to say nxn Matrix inversion has $O(n^3)$ complexity [en.wikipedia.org/wiki/… Or such as when you take 2D-DFT you expect the algorithm to take 4*4=16 times longer when you double the dimension N of an image (assuming square again) Because it is more natural to set N to control image size, rather than the total number of pixels... $\endgroup$ – Fat32 Jan 7 '16 at 23:33
  • $\begingroup$ Well for matrices and matrix inversion $n$ is kind of implicit as non-square matrices do not have inverses. An image however can have two or more differently sized dimensions. The most important part is being careful about defining the variables so there is no misunderstanding. $\endgroup$ – mathreadler Jan 8 '16 at 6:07
  • $\begingroup$ I don't know what to say. Practically speaking, for image processing, as the aspect ratio of an image will be kept fixed during almost all 2D operations, any increase in one dimension will result in a quadratic increasing in the number of pixels. So it is practically a more intuitive notation to refer to dimensions of the image rather than number of pixels. Also in available image-books that I see, instead of a big-O notation to display the complexity, they prefer to use an approximation of number of operations, with respect to dimensions of images. And I consider this as the standard way. $\endgroup$ – Fat32 Jan 8 '16 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.