# Tag Info

## Hot answers tagged 2d

11

I have taken @Phonon's answer and modified it somewhat so that it uses the GCD approach on just the top row and left column, rather than on row/column sums. This seems to handle pathological cases a little better. It can still fail if the top row or left column are all zeroes, but these cases can be checked for prior to applying this method. function [X, Y, ...

10

Got it! Posting MATLAB code, will post an explanation tonight or tomorrow % Two original arrays N = 3; range = 800; a = round( range*(rand(N,1)-0.5) ) b = round( range*(rand(1,N)-0.5) ) % Create a matrix; M = a*b; N = size(M,1); % Sanity check disp([num2str(rank(M)) ' <- this should be 1!']); % Sum across rows and columns Sa = M * ones(N,1); Sb = ones(...

9

Your diagram is incorrect. Computing the 2D-FFT of a 8x8 matrix is not the same as computing the 1D-FFT of a 1x64 vector. A 2D-FFT is "probing" your signal with templates which have both an horizontal and vertical frequency. A signal with a low horizontal frequency and a null vertical frequency is a progressive horizontal gradient. A signal whose vertical ...

7

Maybe I'm trivializing the problem, but it seems like you could: Break the $N$-by-$M$ matrix $\mathbf{A}$ into rows $\mathbf{a_i}$, $i = 0, 1, \ldots , N-1$. For each row index $j > 0$: Elementwise divide $\mathbf{a_j}$ by $\mathbf{a_0}$ to yield the ratio of each element in row $j$ to its counterpart in row zero $\mathbf{r_j}$. This would need to be ...

6

As others have mentioned, performing a 2D FFT on the kernel will give you the frequency response of the filter. However, it's worth mentioning that 2D filters can be analyzed using the Z-transform, which may or may not provide deeper insight, depending on the filter (and what you want to know). For example, given the kernel you specified, the corresponding ...

5

There are various methods on 2d interpolation (this one, and this one). But most of them considered at least 4 points rather than 2. The simplest 2d interpolation is 3 1d interpolation, in which you interpolate the points between (x1-d1, y1-d2) and (x1+d1, y1-d2) as (x2,y2), then you interpolate the points between (x1-d3, y1+d4) and (x1+d3, y1+d4) as (x3,y3)....

5

Your code uses the phase for the reconstruction. Have a look at the output of fft2(x); they are complex numbers, i.e. the contain phase and magnitude. Have a look at this code: %% [x,map] = imread('http://www.cs.cmu.edu/~chuck/lennapg/lena_std.tif'); %import image %% i = rgb2gray(x); % to greyscale I = fft2(i); % 2D FFT I = fftshift(I); % centre mag = ...

4

Yes, you can always use pixel units for $\sigma$. In 2-D you will have $\sigma_X$ and $\sigma_Y$.

4

the simplest interpolation method is nearest neighbour. If you have 4 points with values given by Ms the interpolated value is given by P = f(x,y): P$\ = f(x,y)$ = M_11 if $\ |x-x_1|<= |x-x_2|$ and $\ |y-y_1|<= |y-y_2|$, = M_12 if $\ |x-x_1|< |x-x_2|$ and $\ |y-y_2|< |y-y_1|$, = M_21 if $\ |x-x_2|< |x-x_1|$ and $\ |y-y_1|< |y-y_2|$, ...

4

1) The first equation should look like: h_pred = ifft2 ( fft2(k) ./ fft2(x) ). You have a small typo there, I believe. Make sure you first zero-pad the kernel to the size of image. 2) MATLAB also has a blind deconvolution function: http://www.mathworks.com/help/images/ref/deconvblind.html I don't know if you are referencing to this one, but for Toeplitz ...

4

Please help me understand why in image processing, transformation along both axes is needed. A one dimensional signal describes how does a quantity vary across, usually, time. Time, commonly represented by the symbol $t$, is the only parameter required to describe completely the signal at $t$. A two dimensional signal describes how does a quantity vary ...

4

Approximation by the real part of a weighted sum of separable complex Gaussian component kernels Figure 1. The proposed scheme illustrated as 1-d real convolutions ($*$) and additions ($+$), for cut-off frequency $\omega_c = \pi/4$ and kernel width $N=41$. Each the upper and the lower half of the diagram is equivalent to taking the real part of a 1-d ...

3

If you have image in the spatial domain, in order to calculate its DFT transform you should use fft. Once you have its DFT in order to get back to the spatial domain use the function ifft. Either way, the DFT transform gives you the data in the [0, 2pi] axis. Use fftshift to move it into the [-pi, pi] domain as seen in the paper. Good Luck. MATLAB Code ...

3

Local contrast enhancement a.k.a. Unsharp masking is a simple, fast method for modeling, then removing, smooth (low-frequency) background noise. In a nutshell, extract a smooth background image with a wide-radius lowpass filter sharper_image = image + c * (image - background), c ~ 10 % or so: highpass Using scipy.ndimage, this is : def sharpen( image, ...

3

Another way is to find a separable approximation $x \otimes y \otimes z$ to your kernel $A$, and see how close it is. Two ways of doing this, i.e. to minimize $|A - x \otimes y \otimes z|$: 1) brute-force optimize $x\ y\ z$; this takes time ~ the sum, not the product, of their lengths 2) for fixed $y$ and $z$, the optimal $x$ is just a projection, so ...

3

The negative of the second derivative of a gaussian kernel as you have described it turns out to be what is called the 'Mexican Hat'. kernel. You can see some of its uses in the wiki. As it stands, such a filter can be used to detect edges. The kernel you have provided can also be used in the same capacity. The best way to be able to tell if a filter is ...

3

The axes in your plot seem to be indexes into an array, as if you were using stem3(Z) instead of stem3(X,Y,Z). Check the example in the documentation.

3

So dealing with generalized functions like the Dirac delta requires some care, and when dealing with N-dimensional versions you need to be very explicit with your notation to keep things straight. I'll denote the 2 dimensional delta function in polar coordinates at the origin as ${}^2\delta(r, \theta) = {}^2\delta(r)$, since for the special case of the ...

3

No you are not doing the separation correctly : The horizontal 1D-DFT of the rows of input will be: $H_1 = \begin{matrix} 2 & 0 & 0 & 0 \\ 2 & 0 & 0 & 0 \\ 2 & 0 & 0 & 0 \\ 2 & 0 & 0 & 0 \\ \end{matrix}$ and the vertical 1D-DFT of the columns of $H_1$ will be: $H_2 = \begin{matrix} 8 & ... 2 If you have the MATLAB Image Processing Toolbox, you could use freqz2: http://www.mathworks.com/help/images/ref/freqz2.html Scipy code for a 2-d DFT/FFT as noted by @endolith and @Mohammad h = array([[0,1,0],[1,-4,1],[0,1,0]]) N=32; figure(); imshow(abs(fft2(h,s=(N,N))),interpolation='nearest'); colorbar() 2 If I remember my wavelet transform correctly, this is what happens. Let's imagine that we are working with only the LOW image at the moment. I perform the first-scale decomposition which gives me the LOW_A0 (approximation) and the three detail coefficient images which are LOW_H0, LOW_V0 and LOW_D0. Then, to perform the second scale decomposition, you take ... 2 you could create a matrix that contains the Fourier basis set in the format that conforms to the vectorized version of your images and use this matrix to compute the fft2. You can therefore get what you want with a simple matrix multiplication. 2 Your matrix looks like this: $$\begin{array}{ccc}X_1(:,1) & \ldots & X_N(:,1)\\\vdots & \ddots & \vdots\\X_1(:,8) & \ldots & X_N(:,8)\end{array}$$ where$X_i,\; i=1,\ldots 64,$are the$8\times 8$image matrices. So$X_i(:,1)$is the first column of the$i^{th}$image (I'm using matlab/octave notation). You said you don't want to ... 2 Instead of nulling the 2 quadrants, multiply them by$i$. Then the real part will be one image and the imaginary part the other image. X = fftshift(fft2( x )); % x is the input (image above) X( 1:floor(size(X,1)/2), 1:floor(size(X,2)/2) ) = ... X( 1:floor(size(X,1)/2), 1:floor(size(X,2)/2) ) * 1i; X( ceil(size(X,1)/2)+1:end, ceil(size(X,2)/2)+... 2 Isotropy is uniformity in all orientations. If something is isotropic, its geometrical information is invariant from direction. The former exhibits a clear difference between the grid directions and the directions at a 45-degree angle to the grid. This is why it is not referred as isotropic. The latter on the other hand, applies the same operation, ... 2 The quadrants of the FFT should be shifted Q1->Q3, Q2->Q4 ... For a [RxC] matrix X this may be accomplished by shifting as: tmpX = shift_row( X, floor(R/2) ) Y = shift_col( tmpX, floor(C/2) ) where shift_row and shift_col is your shift operator in each dimension and floor is the round towards zero operator. For the inverse FFT shift you should shift ... 2 Have you heard of the Hough Transform? It is a possible alternative for tackling your problem. 2 Histogram of the gradient directions: You can also try by computing the gradient directions on every pixel, for instance using the Canny edge detector. You will wrap the angle to the range [0°, 180°). Then compute the histogram of the angles, say with a 1° resolution. The dominant direction should appear as the most populated bin. Instead of merely ... 2 Formally, you are correct. But the question says "should look like this". And not "should be equal too". Apparently, the graph drawn is just a hint of the solution, and one should correctly set the$x$- and$y$-axis markers to get the actual solution, only a shift away with the vector$(-15,-15)$, that could replace this graph based on a$[0,30]^2\$ grid. Try:...

2

If you require two outputs, which belong to a movement in x and the other in y direction, you could start with the assumption, that both movements are independent an simply implement two PID controller, each caring for one direction. It gets interesting at the point where you translate the output of these two controller to signals to the actuators. Here it ...

Only top voted, non community-wiki answers of a minimum length are eligible