Cleaning up blurry images using Matlab - matlab

I want to take an image of blurry cylindrical objects and get rid of the blur, basically sharpen the image. How do I do that in Matlab?

See the "sharpening" section in http://www.aquaphoenix.com/lecture/matlab10/page3.html.

You can do it with filters.
See here, section 10.2.4 here: http://www.aquaphoenix.com/lecture/matlab10/page3.html

In addition to all the good answers by others: for the very very simple inputs, you can simply threshold the image if you just need the boundary of those cylinders.

Related

imregtform giving "Registration failed because optimization diverged." error in matlab

I am trying to align an atlas on a brain section via shape similarity. I converted both images to grayscale and filled them in white like so:
Section:
Atlas:
I tried aligning them by similarity using imregtform. However I get the error "Registration failed because optimization diverged." Is there a value in the optimizer that needs to be changed?
Or is there an easier way to do this in MATLAB?
I do not actually have the Image Processing Toolbox, but you should take a look at some of the help files. For instance, Mathworks has many sections online discussing how you can do image processing, including alignment. This link is somewhat a top level discussion (http://www.mathworks.com/help/images/index.html#spatial-transformation-and-image-registration) and this seems like it might be a great tool for you to do image alignment using the control point alignment technique (http://www.mathworks.com/help/images/point-mapping.html).
I hope this helps point you in the right direction. With out having the toolbox, I can't try the suggested tools.
Unfortunatly, Matlabs image registration only offers linear (geometric) transformations atm. That is, only translation, rotation, scale, and shear is allowed. This is not enough for your images since you have local distortions.
What you need is a non-rigid (elastic) registration. You can find some codes for this in the file-exchange.

find center points/ segment white blobs in binary images

In the shown image, I need to find the center points of the white blobs or I need to segment each white blob (to get an image which only contains that blob) from the background.
What is the efficient way to do it?
Seems this is what exactly you are looking for: Image Segmentation Tutorial ("BlobsDemo").
It contains demo to illustrate simple blob detection, measurement, and filtering. First it finds all the objects, then filters results to pick out objects of certain sizes. The basic concepts of thresholding, labeling, and regionprops are demonstrated with examples.
You need to use watershed algoritm for segmentation.
http://www.mathworks.com/help/images/ref/watershed.html
After segment cells use regionprops function.

High Dynamic Range (HDR) from exposure bracketing of grayscale images

I have one question about High Dynamic Range (HDR) images. I want to creat a high dynamic range image from exposure bracketing of grayscale images using matlab. Matlab only support creating HDR image from RBG images. I did google search but there is not many results that related to my topic. Can you advise me some papers or algorithms that could hepl me out.
thanks for any help in advance.
What about replacing grayscale image to RGB image? I haven't used HDR modules, but it maybe works.
rgbImg = zeros(size(grayImg,1), size(grayImg,2), 3);
rgbImg(:,:,1)=grayImg;
rgbImg(:,:,2)=grayImg;
rgbImg(:,:,3)=grayImg;
The HDR Toolbox for MATLAB supports building greyscale images, please have a look at:
https://github.com/banterle/HDR_Toolbox
or
http://www.advancedhdrbook.com
It also supports SIFT and WARD alignment, if you have not use a tripod for capturing images.

Algorithm for laying out images of different sizes in a grid-like way

I'm trying to lay out images in a grid, with a few featured ones being 4x as big.
I'm sure it's a well known layout algorithm, but i don't know what it is called.
The effect I'm looking for is similar to the screenshot shown below. Can anyone point me in the right direction?
UPDATED
To be more specific, lets limit it to the case of there being only the two sizes shown in the example. There can be an infinite number of items, with a set margin between them. Hope that clarifies things.
There is a well-known layout algorithm called treemapping, which is perhaps a bit too generic for your specific problem with some images being 4x as big, but could still be applicable particularly if you decide you want to have arbitrary sizes.
There are several different rectangular treemap algorithms, any of which could be used to visualise photos. Here is a nice example, which uses the strip algorithm to lay out photos with each size proportional to the rating of the photo.
This problem can be solved with a heatmap or a treemap. Heatmaps often use space-filling-curves. A heatmap reduces the 2d complexity to a 1d complexity. A heatmap looks like a quadtree. You want to look for Nick's hilbert curve quadtree spatial index blog.

Using imtophat in MATLAB

I'm trying to do top hat filtering in MATLAB. The imtophat function looks promising, but I have no idea how to use it. I don't have a lot of work with MATLAB before. I am trying to look find basically small spots several pixels wide that are local maxima in my 2 dimensional array.
I think you have more problem undertanding how to use STREL, than IMTOPHAT. The later can be described as simple threshold but per structural element, not the whole image.
Here is another good examples of using STREL and IMTOPHAT:
http://www.mathworks.com/matlabcentral/fx_files/2573/1/content/html/R14_MicroarrayImage_CaseStudy.html
This series of posts on Steve Eddins blog might be useful for you:
http://blogs.mathworks.com/steve/category/dilation-algorithms/
tophat is basically an "opening" procedure followed by a subtraction of the result from the original image. the best and most helpful explanation of opening I've found here:
http://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm
"The effect of opening can be quite easily visualized. Imagine taking
the structuring element and sliding it around inside each foreground
region, without changing its orientation. All pixels which can be
covered by the structuring element with the structuring element being
entirely within the foreground region will be preserved. However, all
foreground pixels which cannot be reached by the structuring element
without parts of it moving out of the foreground region will be eroded
away."
The documentation on imtophat has an example .. did you try it? The following images are from the MATLAB documentation.
Code
I = imread('rice.png');
imshow(I)
se = strel('disk',12);
J = imtophat(I,se);
figure, imshow(J,[])
Original
(image source: mathworks.com)
Top Hat with a disk structuring element
(image source: mathworks.com)