am trying to apply some pre process functions to the image of cars for my graduation project License plate recognition but i face an issue the picture looks poor
The Orignial image enter image description here
1- Convert to Grayscale.
2- Gaussian Blur with 3x3 or 5x5 filter.
3- Apply Sobel Filter to find vertical edges.
4- Threshold the resultant image to get a binary image.
5- Apply a morphological close operation using suitable structuring element. enter image description here
Question is
How can i optimize the picture to be able to get perfect result in the next steps
private: System::Void btnProcess_Click(System::Object^ sender, System::EventArgs^ e) {
cv::Mat imgOriginalScene;
cv::Mat imgGrayscale;
cv::Mat imgGaussianBlur;
cv::Mat imgCannyEdgeDetection;
cv::Mat imgMorphologyEx;
cv::Mat imgScaled;
cv::Mat imgPlate;
cv::Mat imgAbove;
cv::Mat imgThresh;
if (file_path_temp != nullptr)
{
IntPtr pointer_temp = Marshal::StringToHGlobalAnsi(file_path_temp);
const char* input_location = static_cast<const char*>(pointer_temp.ToPointer());
imgOriginalScene = cv::imread(input_location, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
Marshal::FreeHGlobal(pointer_temp);
if (!imgOriginalScene.empty())
{
// first step convert the image to the Gray scale image
cv::cvtColor(imgOriginalScene, imgGrayscale, CV_BGR2GRAY);
// apply Guassin Blur with 3x3 or 5x5
cv::GaussianBlur(imgGrayscale, imgGaussianBlur, cv::Size(3,3),0 );
// apply the threshold
cv::adaptiveThreshold(imgGaussianBlur, imgThresh, 255.0, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY_INV, 19, 9);
// apply Canny edge detection
cv::Canny(imgThresh, imgCannyEdgeDetection, 35, 90);
cv::Mat structuringElement = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3));
cv::morphologyEx(imgCannyEdgeDetection, imgMorphologyEx, cv::MORPH_CLOSE, structuringElement);
cv::imwrite("temp/temp.bmp", imgMorphologyEx);
System::Drawing::Graphics^ graphics = PicBoxCar->CreateGraphics();
System::Drawing::Bitmap^ b = gcnew System::Drawing::Bitmap("temp/temp.bmp");
System::Drawing::RectangleF rect(0, 0, (float)PicBoxCar->Width, (float)PicBoxCar->Height);
graphics->DrawImage(b, rect);
delete b;
}
}
else {
MessageBox::Show("Cannot open this image please choose another one !!", "Path:");
}