User1781154883 posted
Hi! I am developing an application in ASP.NET that takes an image, that have been created with a digital camera or camera phone, and processes it, to get data from it. The image taken by the user will be of a square in some kind of magazine or newpaper, with
a white background and the border of the square should be black. What I am trying to do is to find the square, or the corners of the square, in the image, using ASP.NET code. If the user always took the picture directly above the square without any rotation
and blur this would not be a big problem. But that is hardly not the case most of the times. What I have managed to do so far is to convert the image to gray scale and then made some kind of thresholding so I will end up with just white and black pixels. This
will make the square very visible in the image, but so will other dark object, even if alot is taken out in the tresholding. Finding one of the corners in the square, and always be positively sure that you have found it, would solve alot. Then I think I can
manage to do the rest. In my solution now, I will sometimes find a corner, but it does not work for many images. Does some one have an idea of how to solve this problem? I have tried different ways of search for objects in the image by looking at all pixels,
but I really dont know how to see the difference between the corner of the square and an object. Is it possible to search for patterns in the image? like if I search the image after objects that are similar to a corner of a square. I would really like some
help with this problem. All kinds of ideas are welcomed! Best Regards Andreas Viklund UMEA, Sweden

User-680512290 posted
This is definitely a challenge. What you are trying to do is not simple! However I have just been looking at some interesting stuff which might be of interest to you. Have a look on Google for 'convex hulls'. Implementing such an algorithm may help with finding
the exterior of the shape in the digitised image (photo). What you could do is convert each pixel in the image to a vector point representation, and then run this resulting set of points through an algorithm to compute the convex hull. Generating the convex
hull has the effect of producing a vector representation of connected points which lie on the perimeter of the set of input points. Points which lie inside this perimeter are discarded by the algorithm. I believe that the convex hull is the first step in most
'best fit rectangle' algorithms. You could then go on to find the best fit rectangle (with regards to rotation, width and height) and use this as a guide for what ever you need to do. You can then use this rectangle to crop and adjust rotation of the input
image. Effectively this should mean that your bitmap is now aligned properly and extra space cropped off. It might be worth looking into some OCR algorithms too, but I'm not exactly sure what you are trying to do. What you have done already will be useful
as a first step as it will eliminate most of the noise on the source image. What type of data are you trying to extract from the image? Hope that helps GW