No Idea with what to start in this case i have to extract the red block image from following tiff Image
After extracting I have to read the graph and get output as follows :- if 1 - Off Duty 2 - Sleeper Berth 3 - Driving 4 - On Duty then following graph Should give as 22222243333131331332222 . what algorithm should be used I am using C# as programming Language
Maybe MODI will help you:
http://www.codeproject.com/Articles/29172/Converting-Images-to-Text-using-Office-2007-OCR-Op
Updated:
I think, you tried correctly way (AForge.net). With AForge.Math.Geometry.SimpleShapeChecker class, you will find all rectangles. I will try again.
Updated
with Aforge.net you may compare two image. In your problem, you need compare with original empty cell(standard cell) each cell. And order by similarity, so first 24 cells are (that most not similar cells) that you need.
like this:
private void ProccessBitmap(Bitmap img, Bitmap original_cell)
{
int cellWidth = img.Width / 24;
int cellHeight = img.Height / 4;
IList<KeyValuePair<float, Rectangle>> table = new List<KeyValuePair<float, Rectangle>>();
Bitmap cell;
Rectangle rect;
AForge.Imaging.ExhaustiveTemplateMatching tm = new AForge.Imaging.ExhaustiveTemplateMatching(0);
for (int rowIndex = 0; rowIndex < 4; rowIndex++)
{
for (int colIndex = 0; colIndex < 24; colIndex++)
{
rect = new Rectangle(colIndex * cellWidth, rowIndex * cellHeight, cellWidth, cellHeight);
cell = img.Clone(rect, img.PixelFormat);
var matchings = tm.ProcessImage(original_cell, cell);
table.Add(new KeyValuePair<float, Rectangle>(matchings[0].Similarity, rect));
cell.Dispose();
}
}
using (Graphics gr = Graphics.FromImage(img))
{
gr.DrawRectangles(new Pen(Color.Red, 3.0f), table.OrderBy(a => a.Key).Take(24).Select(a => a.Value).ToArray());
}
pictureBox1.Image = img;
}