Finding the maximum area of a rectangular damaged Manuscript in Matlab - matlab

I have this image below. How can I find the original area of the manuscript? I used imfill and was able to find the area within the boundaries, but I need the maximum area of just the manuscript itself within the image
image: Damaged Manuscript

You can calculate the bounding box / bounding rectangle to approximate the original area.
Use regionprops to calculate the property BoundingBox.
ConvexHull might help as well but I guess the resulting area would tend to be to small.
http://de.mathworks.com/help/images/ref/regionprops.html

Related

Finding the centers of overlapping circles in a low resolution grayscale image

I am currently taking my first steps in the field of computer vision and image processing.
One of the tasks I'm working on is finding the center coordinates of (overlapping and occluded) circles.
Here is a sample image:
Here is another sample image showing two overlapping circles:
Further information about the problem:
Always a monochrome, grayscale image
Rather low resolution images
Radii of the circles are unknown
Number of circles in a given image is unknown
Center of circle is to be determined, preferably with sub-pixel accuracy
Radii do not have to be determined
Relative low overhead of the algorithm is of importance; the processing is supposed to be carried out with real-time camera images
For the first sample image, it is relatively easy to calculate the center of the circle by finding the center of mass. Unfortunately, this is not going to work for the second image.
Things I tried are mainly based on the Circle Hough Transform and the Distance Transform.
The Circle Hough Transform seemed relatively computationally expensive due to the fact that I have no information about the radii and the range of possible radii is large. Furthermore, it seems hard to identify the (appropriate) pixels along the edge because of the low resolution of the image.
As for the Distance Transform, I have trouble identifying the centers of the circles and the fact that the image needs to be binarized implies a certain loss of information.
Now I am looking for viable alternatives to the aforementioned algorithms.
Some more sample images (images like the two samples above are extracted from images like the following):
Just thinking aloud to try and get the ball rolling for you... I would be thinking of a Blob, or Connected Component analysis to separate out your blobs.
Then I would start looking at each blob individually. First thing is to see how square the bounding box is for each blob. If it is pretty square AND the centroid of the blob is central within the square, then you have a single circle. If it is not square, or the centroid is not central, you have more than one circle.
Now I am going to start looking at where the white areas touch the edges of the bounding box for some clues as to where the centres are...

Area of Bounding Box of an object matlab

I have objets have different shapes and my aim is to find ratio between object area and its Bounding Box area. There is no problem to find object area but I did not find a way to get Bounding Box area.
Is there any way or any exist function in matlab to calculate Bounding Box area?
But, you know the bounding box? If you dont, use regionprops(Imgbw,'BoundingBox')
And you will get it.
Once you have it, its kinda easy. Is just computing the area of a square. Regionprops will give you [x y] and [x_width y_width]. Im sure you are capable of calculating the area of a square with the size of its sides.

Method to fill in any size hole

I'm working on a fingerprint recognition project but I need to pre-process the image. I go through the following process.
1) Binarization
2) Filtering to removing the "stair-step" effect; i.e smoothing
3) Thin the lines
I'm adding in a step that I'm trying to develop that will fill in any holes that are left after thinning. I'm trying to accomplish this as follows.
4a) Use bwlabel to find regions (I might consider using bwmorp(...,'shrink') to just leave the "blobs" but doing this reduces the size of the blob a little).
4b) Find all regions that do not have the maximum area
4c) Use the location of these regions to shrink these "blobs" to points.
But how can I apply shrink at specified locations?
Binarization
Filtering
Thinning
Hole filling
I am Not sure if I understood the question correctly. But can you take complement of the thinned image and then use bwlabel. After that, count the number of pixels belonging to each label. Apply your criteria to select labels and get their locations. After that, you can use imfill(bw,locations) command.
If you have a region you want to shrink to a point then calculate the center of mass for the region. Do this by just averaging the x and y coordinates of each point in the blob. Set the region pixels to black and the center of mass to white.
The problem that I am having is trimming off the ridges to just leave the filled areas while avoiding erosion of the filled areas (if I were to use erode the ridges would disappear but also reduce the size of the area).
You don't really have to worry about erosion of the small regions as it will have little impact on the center of mass, and you point will still end up going to an appropriate location.

How Do I Find The Bounding Box For All Regions?

I'm using the MNIST digit images for a machine learning experiment, and I'm trying to center each image based on position, rather than the center of mass that they are centered on by default.
I'm using the regionprops class, BoundingBox method to extract the images. I create a B&W copy of the greyscale, use this to determine the BoundingBox properties (regionprops works only B&W images) and then apply that on the greyscale original to extract the precise image rectangle. This works fine on ~98% of the images.
The problem I have is that the other ~2% of images has some kind of noise or errant pixel in the upper left corner, and I end up extracting only that pixel, with the rest of the image discarded.
How can I incorporate all elements of the image into a single rectangle?
EDIT: Further research has made me realise that I can summarise and rephrase this question as "How do I find the bounding box for all regions?". I've tried adjusting a label matrix so that all regions are the same label, to no avail.
You can use an erosion mask with the same size of that noise to make it totally disappear " using imerode followed by imdilate to inverse erosion ", or you can use median filter

what does MajorAxisLength property in regionprop matlab function mean?

I am using regionprop function in matlab to get MajorAxisLength of an image. I think logically this number should not be greater than sqrt(a^2+b^2) in wich a abd b are the width and heigth of the image. but for my image it is. My black and white image contains a black circle in the center of the image. I think this is strange. Can anybody help me?
Thanks.
If you look at the code of regionprops (subfunction ComputeEllipseParams), you see that they use the second moment to estimate the ellipsoid radius. This works very well for ellipsoid-shaped features, but not very well for features with holes. The second moment increases if you remove pixels from around the centroid (which is, btw, why they make I-beams). Thus, the bigger the 'hole' in the middle of your image, the bigger the apparent ellipsoid radius.
In your case, you may be better off using the extrema property of regionprops, and to calculate the largest radius from there.