How to exclude the transparent parts which are not rectangles when conducting Fourier analyses on PNG images? - matlab

Some PNG images have transparent backgrounds. We can get maps of transparent degree from PNG images through imread.
It's easy to exclude the transparent parts in Fourier analysis if they are rectangles. However, how to exclude the transparent parts which are not rectangles in Fourier analysis (using fft2)?
In this case, how to use the maps of transparent degree in conducting Fourier analysis?

Related

Extract shapes of curves from binary images

I am analyzing back bone formation in zebrafish embryos and in this picture:
I would like to extract the shape and position of the horizontal lines/curves. Here is a little information about the image. The image at the top is already a segmented image through morphological processing and by using the MATLAB active contour function. The region between the two vertical lines is where the spinal cord develops and the horizontal lines on either side of the spinal cord later develop into ribs. The image at the bottom is where I have applied a canny edge detector. I have a time series of the development of ribs and I would now like to extract the shape and position of the horizontal curves. This is a follow up of my previous question:
Identify curves in binary image
I am guessing this will involve some kind of curve fitting module to obtain the shapes. Any ideas to go about this is very welcome.
Thanks

3D reconstruction based on stereo rectified edge images

I have two closed curve stereo rectified edge images. Is it possible to find the disparity(along x-axis in image coordinates) between the edge images and do a 3D reconstruction since I know the camera matrix. I am using matlab for the process. And I will not be able to do a window based technique as it's a binary image since a window based technique requires texture. The question how will I compute the disparity between the edge images? The images are available in the following links. Left Edge image https://www.dropbox.com/s/g5g22f6b0vge9ct/edge_left.jpg?dl=0 Right Edge Image https://www.dropbox.com/s/wjmu3pugldzo2gw/edge_right.jpg?dl=0
For this type of images, you can easily map each edge pixel from the left image to its counterpart in the right image, and therefore calculate the disparity for those pixels as usual.
The mapping can be done in various ways, depending on how typical these images are. For example, using DTW like approach to match curvatures.
For all other pixels in the image, you just don't have any information.
#Photon: Thanks for the suggestion. I did what you suggested. I matched each edge pixel in the left and right image in a DTW like fashion. But there are some pixels whose y-pixel coordinate value differ by 1 or 2 pixels, albeit they are properly rectified. So I calculated the depth by averaging those differing(up to 2-pixel difference in y-axis) edge pixels using least squares method. But I ended getting this space curve (https://www.dropbox.com/s/xbg2q009fjji0qd/false_edge.jpg?dl=0) when they actually should have been like this (https://www.dropbox.com/s/0ib06yvzf3k9dny/true_edge.jpg?dl=0) which is obtained using RGB images.I couldn't think of any other reason why it would be the case since I compared by traversing along the 408 edge pixels.

Align blurred and sharp rectangles

Looking to align (register) and find the linear transformation between a pair of rectangular borders. One is a blurred and transformed version of the other (unknown blur kernel and a similarity transformation - rotation, translation and scale).
This is the input pair of images:
So far, I've tried registering the pair of images using both mutual information and brightness constancy. Namely, with the imregtform function from MATLAB's image processing toolbox. This is the best result I've been able to obtain (displaying a fused image with the blurred pixels in channels R,B and the sharp in channel G):
Which is not bad but is not perfect. Note in the right side the blurriness is not symmetric around the sharp rectangles.
I'm wondering if there is any other, simpler way to do this. Note, that I have complete control over the pattern! If anyone has an idea of a better pattern to use for alignment it can certainly help!
you can try affine registration, resize the bigger image and use DROP http://www.mrf-registration.net/deformable/index.html, it does more sophisticated stuff like discrete optimization using patch based matching, followed by b-spline interpolation to deform images

Filter Noise in MatLab

Hi I'm attempting to filter an image with 4 objects inside using MatLab. My first image had a black background with white objects so it was clear to me to filter each image out by finding these large white sections using BW Label and separating them from the image.
The next image has noise in it though. Now I have an image with white lines running through my objects and they are actually connected to each other now. How could I filter out these lines in MatLab? What about Salt and pepper noise? Are there MatLab functions that can do this?
Filtering noise can be done in several ways. A typical noise filtering procedure will be something like threshold>median filtering>blurring>threshold. However, information regarding the type of noise can be very important for proper noise filtration. For examples, since you have lines in your image you can try to use a Hough transform to detect them and take them out of the play (or houghlines). Another approach can be to implement RANSAC. For salt & pepper type of noise, one should use medfilt2 with a proper window size that captures the noise characteristics (for example 3x3 window will deal well with noise fluctuations that are 1 pixel big...).
If you can live with distorting the objects a bit, you can use a closing (morphological) filter with a bit of contrast stretching. You'll need the image processing toolbox, but here's the general idea.
Blur to kill the lines otherwise the closing filter will erase your objects. You can use fspecial to create a Gaussian filter and imfilter to apply it
Apply the closing filter to the image using imclose with a mask that's bigger then your noise, but smaller then the object pieces (I used a 3x3 diamond in my example).
Threshold your image using im2bw so that every pixel gets turned to pure black or pure white based
I've attached an example I had to do for a school project. In my case, the background was white and objects black and I stretched between the erosion and dilation. You can't really see the gray after the erosion, but it was there (hence the necessity for thresholding).
You can of course directly do the closing (erosion followed by dilation) and then threshold. Notice how this filtering distorts the objects.
FYI usually salt-and-pepper noise is cleaned up with a moving average filter, but that will leave the image grayscale. For my project, I needed a pure black and white (for BW Label) and the morphological filters worked great to completely obliterate the noise.

thresholding an image based on gradient

I have multiple simple circle objects in grid of an image from which I want to create mask image for the objects. A gotcha is that light intensity for each object is different. So simple thresholding would not create a mask.
As a solution, I want to threshold based on gradient. Basically, I'd like to first find the circle with edge detection and make inside of the circle white and outside black. But this is really slow. Is there any better way to do this on matlab?
I would create a low-pass filtered version of the image, and use it as the threshold. The "strength" of the filter should be tuned carefully in order to make the result follow the distribution of light intensity, but this is not that hard.
(This approach worked for me when I had to extract the contour of blood vessels from brain-surface images, few years ago.)