Console How to implement DilateCommand and DespeckleCommand for image
Moderator: Alex
Console How to implement DilateCommand and DespeckleCommand for image
I'm running an OMR application and need to preprocess a DilateCommand for images.
How can this be done, any short code example or a hint on how to do would be appreciated.
(Running C#)
Regards Klaus.
How can this be done, any short code example or a hint on how to do would be appreciated.
(Running C#)
Regards Klaus.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hello Klaus,
Please do the following test:
Please do the following test:
- Run our Forms Processing Demo.
- Select "Template matching => Image imprint generator preprocessing..." menu, dialog for preprocesing of image imprint generator" will appear.
- Check the "Enable image processing" checkbox, add "Dilate filter" to the commands, which must be applied to processing image, and press the "Ok" button.
- Try to process OMR form and see the result.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hello Alex,
thanks for very fast answer,
with the forms example I did an it works perfect.
After that I tried to implement into the console application without running a form.
I want to run it as 'inPlace', no error occurs, but it seems that image is not dilated (because the result is not the same as in forms applilcation).
How have I to implement the imprint generator preprocessor (I tried to do the same way as in console examples with 'Binarization', may be that is incorrect?)
Regards Klaus.
thanks for very fast answer,
with the forms example I did an it works perfect.
After that I tried to implement into the console application without running a form.
I want to run it as 'inPlace', no error occurs, but it seems that image is not dilated (because the result is not the same as in forms applilcation).
How have I to implement the imprint generator preprocessor (I tried to do the same way as in console examples with 'Binarization', may be that is incorrect?)
Regards Klaus.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hello Klaus,
You need to set the image processing command in key zone recognizer if you want to preprocess image before form recognition. This can be done using the KeyZoneRecognizerCommand.ImagePreprocessing property.
VintaSoft Imaging .NET SDK contains the FormsProcessingConsoleDemo console project, which demonstrates how to recognize filled form using template form or align image according to the template image in .NET.
Please see source codes of this project.
Program.cs file has the CreateImageImprintGenerator method with the following code:
For preprocessing of source image before key zone recognition you need to modify code of CreateImageImprintGenerator method to the following code:
Best regards, Alexander
You need to set the image processing command in key zone recognizer if you want to preprocess image before form recognition. This can be done using the KeyZoneRecognizerCommand.ImagePreprocessing property.
VintaSoft Imaging .NET SDK contains the FormsProcessingConsoleDemo console project, which demonstrates how to recognize filled form using template form or align image according to the template image in .NET.
Please see source codes of this project.
Program.cs file has the CreateImageImprintGenerator method with the following code:
Code: Select all
private static ImageImprintGeneratorCommand CreateImageImprintGenerator(string imprintGeneratorType)
{
// select image imprint generator type
switch (imprintGeneratorType)
{
case "Line":
case "":
return new ImageImprintGeneratorCommand(new KeyLineRecognizerCommand());
case "Lpattern":
return new ImageImprintGeneratorCommand(new KeyMarkRecognizerCommand());
case "All":
KeyZoneRecognizerCommand[] command = new KeyZoneRecognizerCommand[] { new KeyLineRecognizerCommand(), new KeyMarkRecognizerCommand() };
return new ImageImprintGeneratorCommand(command);
default:
Console.WriteLine("Unknown imprint generator type. Using default type: Line.");
return new ImageImprintGeneratorCommand(new KeyLineRecognizerCommand());
}
}
Code: Select all
private static ImageImprintGeneratorCommand CreateImageImprintGenerator(string imprintGeneratorType)
{
// select image imprint generator type
switch (imprintGeneratorType)
{
case "Line":
case "":
KeyLineRecognizerCommand keyLineRecognizerCommand = new KeyLineRecognizerCommand();
keyLineRecognizerCommand.ImagePreprocessing = new DilateCommand();
return new ImageImprintGeneratorCommand(keyLineRecognizerCommand);
case "Lpattern":
return new ImageImprintGeneratorCommand(new KeyMarkRecognizerCommand());
case "All":
KeyZoneRecognizerCommand[] command = new KeyZoneRecognizerCommand[] { new KeyLineRecognizerCommand(), new KeyMarkRecognizerCommand() };
return new ImageImprintGeneratorCommand(command);
default:
Console.WriteLine("Unknown imprint generator type. Using default type: Line.");
return new ImageImprintGeneratorCommand(new KeyLineRecognizerCommand());
}
}
Re: Console How to implement DilateCommand and DespeckleCommand for image
Thank you Alex, I think that helps will try it tomorrow.
Regards
Klaus.
Regards
Klaus.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hi Alex,
that helpt and the Dilate Command is running as expected. Thanks for that.
But: how to add a second/third preprocess command, such as despeckle or the whole ocrpreprocess command.
I couldn't find an 'Add-method' for the 'keyLineRecognizerCommand.ImagePreprocessing', only new.
Regards
Klaus.
that helpt and the Dilate Command is running as expected. Thanks for that.
But: how to add a second/third preprocess command, such as despeckle or the whole ocrpreprocess command.
I couldn't find an 'Add-method' for the 'keyLineRecognizerCommand.ImagePreprocessing', only new.
Regards
Klaus.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hi Alex,
is there a 'combined command' example for a bulk of prepressing commands?
Or do I make a step by step excecution of different commands in the following way:
// process image in place
command1.ExecuteInPlace(processedImage);
command2.ExecuteInPlace(processedImage);
Doing this uses the second command the result of first command?
Is this correct, bedause it is 'InPlace' what means 'in memory'.
Regards
Klaus.
is there a 'combined command' example for a bulk of prepressing commands?
Or do I make a step by step excecution of different commands in the following way:
// process image in place
command1.ExecuteInPlace(processedImage);
command2.ExecuteInPlace(processedImage);
Doing this uses the second command the result of first command?
Is this correct, bedause it is 'InPlace' what means 'in memory'.
Regards
Klaus.
Re: Console How to implement DilateCommand and DespeckleCommand for image
Hi Klaus,
Sorry for delay. If you need fast response to your question, please send your question to our support at support@vintasoft.com.
You need to use the CompositeCommand class (https://www.vintasoft.com/docs/vsimagin ... mmand.html) if you want to combine several image processing commands.
For using several image processing commands (dilate and despeckle) before key zone recognition you need to modify code of CreateImageImprintGenerator method to the following code:
Best regards, Alexander
Code: Select all
that helpt and the Dilate Command is running as expected. Thanks for that.
But: how to add a second/third preprocess command, such as despeckle or the whole ocrpreprocess command.
I couldn't find an 'Add-method' for the 'keyLineRecognizerCommand.ImagePreprocessing', only new.
You need to use the CompositeCommand class (https://www.vintasoft.com/docs/vsimagin ... mmand.html) if you want to combine several image processing commands.
For using several image processing commands (dilate and despeckle) before key zone recognition you need to modify code of CreateImageImprintGenerator method to the following code:
Code: Select all
private static ImageImprintGeneratorCommand CreateImageImprintGenerator(string imprintGeneratorType)
{
// select image imprint generator type
switch (imprintGeneratorType)
{
case "Line":
case "":
Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase[] commands =
new Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase[] {
new Vintasoft.Imaging.ImageProcessing.Filters.DilateCommand(),
new Vintasoft.Imaging.ImageProcessing.Document.DespeckleCommand()
};
KeyLineRecognizerCommand keyLineRecognizerCommand = new KeyLineRecognizerCommand();
keyLineRecognizerCommand.ImagePreprocessing = new Vintasoft.Imaging.ImageProcessing.CompositeCommand(commands);
return new ImageImprintGeneratorCommand(keyLineRecognizerCommand);
case "Lpattern":
return new ImageImprintGeneratorCommand(new KeyMarkRecognizerCommand());
case "All":
KeyZoneRecognizerCommand[] command = new KeyZoneRecognizerCommand[] { new KeyLineRecognizerCommand(), new KeyMarkRecognizerCommand() };
return new ImageImprintGeneratorCommand(command);
default:
Console.WriteLine("Unknown imprint generator type. Using default type: Line.");
return new ImageImprintGeneratorCommand(new KeyLineRecognizerCommand());
}
}
Re: Console How to implement DilateCommand and DespeckleCommand for image
Thank you Alex.
This was what I was looking for.
Real great support!
Regards
Klaus.
This was what I was looking for.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Real great support!
Regards
Klaus.