Image Processing: book contour - image

I have a shelf full of books, and I want to detect the contours of each book. The problem is that the shelf is stacked with books in horizontal and vertical. Sometimes the contour is not well defined due to shadows or because one book is slightly bigger than the other. Canny algorithm is not giving me right contour of each book. It just gives me the contour of the whole stack.
As an alternative, I thought in selecting manually some ROI (region of interest) of some books, and then find similar regions. I don't know if this works, and which image patterns algorithms should I look at.
1 Can you suggest me possible algorithms to detect book contours in this scenario?
2 Is it possible the alternative solution? If so, which algorithms should I look at?
3 Since this is a new area to me, which documentation I should start looking at?

Related

Is there some generic algorithm to calculate the dimensions of a piece of fabric needed to cover a 3D shape

I hope that this is the correct place to ask this kind of question. I am developing a web app to design garden ponds and I need to calculate the shape and size of the foil needed to cover that pond. The pond will provided as a 3D model (threeJS). The shape of the pond will be relatively simple (think one or more rectangular boxes potentially with some stairs).
I am considering folding out the surface of the 3D model into a flat shape, but I do not know how to do that in a generic way. And even if a could od that it would not be the complete solution (but potentially it would be a starting point) I have been searching for a generic algorithm to do this, but so far have not found anything. Does anyone know of an algorithm that I could use for this, or at least something that I could start with.
Some additonal information:
this will be a browser based solution which should show the pool; one option would be ThreeJS since I am somewhat familiar with it
the foil that should cover the pond needs to watertight, so it needs to be one piece. That means that when your put it in the pool, it form rinkle, especially in the corners.

Multi-level object recognition using computer vision

Are there any possible methodologies or algorithms to detect and identify multiple layers of objects (one above the other) using computer vision and image processing?
For example take a look at this image:
(source: shittyfoodmadepretentious.com)
If I were to place a camera on top, will I be able to detect and identify the different layers of fruits.
Also, if not possible with computer vision, which other techniques can I possibly make use of?
Doing this purely with a camera would be very difficult since you don't have any way to know how far away the fruits are. The camera could be looking at a 2D picture of fruit and interpret it the same as a basket.
You could try complementing the camera with a range finding device, ultrasonic or radar to know how far away the fruit is in 3D space.
Another option is if you know what fruit is being observed and can approximate the actual size (diameter of the fruit irl), using similar triangles you could approximate the distance to each fruit and know their location in 3D space. This question seems to have an answer that is detailed in finding distance to known object.

Algorithm to best fit a rectangle

I'm writing an application which measures boxes from pictures. A sample picture after manipulation is shown below:
My application has identified pixels that are part of the box and changed the color to red. You can see that the image is pretty noisy and therefore creates pretty rough looking edges on the rectangle.
I've been reading about edge/corner detection algorithms, but before I pursue one of them I wanted to step back and see if such a complicated algorithm is really necessary. It seems like there probably is a simpler way to go about this, considering I have a few conditions that simplify things:
The image only contains a rectangle, not any other shape.
Each image only has 1 rectangle.
I do not need to be exact, though I'd like to achieve as best fit as I can.
My first go at a simple algorithm involved finding the top most, bottom most, left most and right most points. Those are the 4 corners. That works OK, but isn't super accurate for noisy edges like this. It is easy to eye ball a much better point as the corner.
Can anyone point me towards an algorithm for this?
You have already identified the region of the image that you are interested in(red region).
Using this same logic you should be able to binarize the image. Say the red region then results in white pixels and the rest is black.
Then trace the external contour of the white region using a contour tracing algorithm.
Now you have a point set that represents the external contour of the region.
Find the minimum-area-rectangle that bounds this point set.
You can easily do this using the OpenCV library. Take a look at threshold, findContours, and minAreaRect if you are planning to use OpenCV. Hope this information helps.

What algorithms can be used to simulate a lens that is physically accurate?

I have never really done any optics stuff. Currently reading Optics by Hecht to get a deeper understanding of optics. I need to create a software that can take an image (a simple image, such as a red circle on a white background) and perform operations that will output an image that a person with Hyperopia (farsightedness) would see, when their eyes (or eye) are positioned on the centre of the circle. What algorithms can I use to model a lens for this purpose? Any reference to books, research papers, libraries appreciated.
[i deleted this post because i thought it was too light on details, but since no-one else is replying i've undeleted in case it helps. recently i've found that there's a scientific computing s.o. that might be a better place to ask - http://scicomp.stackexchange.com/]
it really depends on what you want to do.
for something as simple as a simulating what a farsighted person would see when looking at a (nearby) flat image, blurring (as suggested by Domi in comments) is probably fine.
things get progressively more complex when:
what is being imaged contains components at different distances (in simple terms, the blurring for each will be different)
you want to include exact effects of geometric aberrations (like chromatic aberrations on lenses)
you want to include wave-like effects (like diffraction)
for general classical aberrations you have to do physically accurate ray tracing. in practice you may find approximations that give good enough results in exchange for speed (for example, blurring is an extreme approximation). for wave-like effects i am unsure - i guess you extend ray tracing with path lengths.
my copy of hecht is very old, but in the geometrical optics section there's a section on ray tracing, and that whole chapter covers the theory.
remember that, even if blurring is good enough, you still have to work out how much blurring from the exact details of the case, and the geometries involved (basically, you want the point spread function for your system; then you likely approximate that with a gaussian).

Is there some well-known algorithm which turns user's drawings into smoothed shapes?

My requirements:
A user should be able to draw something by hand. Then after he takes off his pen (or finger) an algorithm smooths and transforms it into some basic shapes.
To get started I want to transform a drawing into a rectangle which resembles the original as much as possible. (Naturally this won't work if the user intentionally draws something else.) Right now I'm calculating an average x and y position, and I'm distinguishing between horizontal and vertical lines. But it's not yet a rectangle but some kind of orthogonal lines.
I wondered if there is some well-known algorithm for that, because I saw it a few times at some touchscreen applications. Do you have some reading tip?
Update: Maybe a pattern recognition algorithm would help me. There are some phones which request the user to draw a pattern to unlock it's keys.
P.S.: I think this question is not related to a particular programming language, but if you're interested, I will build a web application with RaphaelGWT.
The Douglas-Peucker algorithm is used in geography (to simplify a GPS track for instance) I guess it could be used here as well.
Based on your description I guess you're looking for a vectorization algorithm. Here are some pointers that might help you:
https://en.wikipedia.org/wiki/Image_tracing
http://outliner.codeplex.com/ - open source vectorizer of the edges in the raster pictures.
http://code.google.com/p/shapelogic/wiki/vectorization - describes different vectorization algorithm implementations
http://cardhouse.com/computer/vector.htm
There are a lot of resources on vectorization algorithms, I'm sure you'll be able to find something that fits your needs. I don't know how complex these algorithms are to implement them, though,

Resources