Assuming that these are simple geometric shapes on relatively simple backgrounds (as opposed to real objects against cluttered backgrounds), then I'd suggest:
1. Determine which pixels are foreground (shapes) and background (everything else) 2. Identify individual blobs (connected sets of foreground pixels of the same type) 3. For each blob, extract meaningful features 4. Train a classifier, based on the extracted features 5. Test the system on new images 6. Celebrate!
In step 2, try using a flood fill. In step 3, there are many features one might try, such as perimeter-to-area ratio. In step 4, the classifier could be any learning algorithm: neural network, linear discriminant, etc.
I have a rectangle(all sides are known). I want to draw X(known number) small rectangles in it.but all of sub rectangles must have same size and a predefined proportion. This should use maximum area in main rectangle when deciding columns and rows.
i.e If my rectangle is 800x320 and i want to draw 32 sub rectangles in it.All 32 sub rectangles must have ratio (4:3)
What will be the number of columns and rows and width/height of sub rectangles?
Superb reason is that this 800x320 was just an example and i put this question in algorithm section, because i want an algorithm to solve it. As every time this algorithm will get different inputs, such as rectangle size, sub controls count and sub controls ratio. and the out put will be (row x columns) and their size.
I guess some trigonometry will surely do it...but can't figure it out so far.
A hint on the procedure. You should maximize the sum of the rectangle areas with some constraint (hence the use of Lagrange multipliers). You requirements give the following constants (supposing all rectangles have the same size):
N the total number of rectangles
w and h, giving the ratio of each rectangle, i.e. ratio w:h
W and H, the width and the height of the bounding rectangle
and the following variables
r the number of rows of the rectangle grid
c the number of columns of the rectangle grid
x defined so that x*w = rectangle width and x*h =rectangle height
You should maximize the total area, i.e. N*h*w*x, while obeying to the following constraints:
N = r*c
W >= c * w * x
H >= r * h * x
Using (generalized ?) Lagrange multipliers you may write the function L: L(x,r,c,j,k,l) = N*h*w*x - (r*c - N)*j - (c*w*x - W)*l - (r*h*x -H)*k
where j,l,k are the Lagrange multipliers.
Now you've to find an extreme of it (i.e. all first derivatives with respect the parameters x,r,c,j,k,l should be zero) and verify it's a solution for your problem. I hope I didn't make silly mistakes. Good luck.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
You're a friend of skelet0n, aren't you? Given the algo [^], you can easily figure out the result (you've just to change N from constant to variable).
No, I'm just me. If rotation is allowed, however, the algorithm given won't take optimal advantage of it. For example, the dimensions I gave allow 30 rectangles of size 100x75 or 75x100 to be placed, but only if some are rotated 90 degrees relative to others. What would be the optimal algorithm to deal with that?
Hi Eddy.. Thank's for your reply.. I am doing my degree in St.Xavier's College, Palayamkottai, India. I am developing a web based application in which i have to display results from popular search engines according to the keyword entered by the user... The number of results to be displayed must be user's choice..
Founded in 1923, as it reads. So you're going to use an existing search-engine? Google would seem the be the obvious choice there. They've got extensive documentation on how to do these kind of things here[^].
Your part lies in making the call to the site for the correct searchquery, reading back the results, and displaying those that you want - I don't expect you to have any problems as it's a rather basic task.