How can I implement image widowing in my image in Java?
Consider the large image, and the region of interest (red):



If you will simply take the Fourier transform of the 8x8 region, the transform is assuming that the image is periodic like this:



The Fourier transform will see artificial directional features across the replicates of the 8x8 region. But if you pad the 8x8 image with zeros to 32x32, these artifacts disappear and the frequency resolution of the discrete Fourier transform is enhanced as a welcome side effect as well:



However, now a new problem is revealed: There are artificial directional features along the boundary lines of the 8x8 region, like in the upper half of the left boundary and in the left half of the upper boundary. A solution is to multiply the 8x8 image with a circularly symmetric window function:



The drawback is that the corners of the image are completely ignored. If you think it is useful, you could extend your region of interest so that you would not null the corners of that 8x8 region.

To test the performance of your dominant direction finding algorithm starting with the 8x8 input image, you can use test images. Start with a flat white 8x8 image. This should not give a dominant direction stronger than some level of approximation error. If it does, make sure that your window function has circular symmetry and that you have normalized fairly the calculation of all direction-specific integrals over the squared magnitude of the Fourier transform. Then try 8x8 images with directionality generated by setting the pixels to values $\cos(ax + by + c)$, where $\text{atan2}(a, b)$ defines the directionality, $x$ and $y$ are the pixel coordinates and $c$ should not affect the analysis result.

If your algorithm passes these tests it should be fine!