MATLAB Optical character recognition - need help - matlab

I have to use mat lab to find a certain letter in a tif text image.In the spatial domain. I have no idea how to do this, and can't find any documentation other than complex code that uses loops, loops are forbidden. Yes, this is an assignment I don't want the answer just some direction on how to even start.
I want to use imfilter and use a letter as a template or filter to imfilter using correlation but from there I have no idea where to go and don't even know what questions to ask to find more info on mat labs site.
The write up makes it seem simple but I know nothing of this subject as I am a beginner so to me this is hard.
thanks

If you have the image processing toolbox I would suggest using the function normxcorr2. It calculates the normalized cross correlation between a template image and a larger image, which I think is what you want.
You don't need any for loops to use it, but the method itself probably uses for loops somewhere hidden in the code. I don't know if that counts..

Related

Understanding Feature Extraction and Feature Vectors in Image Processing?

I am working on a small project in Matlab just because of my interest in image processing and I have not studied a degree or a course related to image processing.
I want to understand a small concept about feature extraction and feature vectors. I have read some articles about that and in general I can understand that, but my question is:
For example, I want to extract some information from different objects of a binary image, the information is about length, width and distance between the objects. In one application I want to extract the features on which I want to apply some algorithms to compute width of all the objects and ignore the length and distance. Can we name this as feature extraction regarding the width? And storing them in different vectors as Feature Vectors?
It makes me think that, I might be complicating the simple things. Should I use some other terminologies for this instead of feature extraction and feature vectors?
Please suggest me if I am going in the right direction or not?
Thank you!
Feature extraction is the process of computing numerical values on regions/objects/shapes/blobs detected in an image. [Sometimes the detection itself can be called extraction and the features need not be numbers.]
The feature values can indeed be stored in vectors, usually they fill a table. Sometimes they are structured in a more complicated way (such as a graph f.i.). Most of the time they are used for classification/recognition purposes or they can just be the output of the process on hand.

Find intercepts in almost flat lines

I have a set of lines (image below) which should meet in a number of points. As you can see, now the angular coefficient doesn't vary noticeably, making intercepts hard to find. What transformation do you suggest to use to make things easier (like some kind of Hough transform), or where do you think I should look for inspiration? Thanks!
I'm working in Matlab but I can switch to Python if needed.
I think you're looking for houghpeaks function (http://www.mathworks.nl/help/images/ref/houghpeaks.html)

Optical Character Recognition Development

I have been trying to develop an OCR engine by myself. After researching the topic a bit I have come to the conclusion that there are 4 major steps involved :
Pre-processing the image [de-skewing, image contrast, binarize, etc.]
Segment the image into the characters [to make it easier to process each character individually]
Identify the chracter through feature extraction / comparison and classification.
Post-processing the image [to increase the chances of getting an optimal solution.]
I am hopelessly lost after the 1st step! Can somebody please help me out by telling how to perform character segregation & feature extraction ? I'll be extremely grateful even if you can provide me a link which points me in the right direction.
Thanks in advance! :)
There is a paper called self-tuning spectral clustering by Zelnik-Manor and Perona. Here is the link to their page for paper and code written in Matlab:
Self-Tuning Spectral Clustering
This method can perform image segmentation. Another thing you may want to look into is topic-modeling on images for feature extraction. Anything by Blei will also be useful.
The Computer Vision System Toolbox now has the ocr function that can save you the trouble.

Estimating an image deblurring/denoising technique

I'm new to image processing and wanted to deblur/denoise some images using Matlab. Example:
Input
Output
I don't know the exact blurring/noising effects by which the second image came about. At first, I normally did so by trial and error of the Wiener deconvolution method, but not able to reach best results.
So my question is, is there a more clever method other than trial and error?
(Note: The output image was obtained from Robot36 radio transmission decoder.)
I'd suggest trying the Richardson-Lucy deblurring algorithm. It is available as a built-in function in the Image Processing Toolbox. It makes use of multiple iterations which you can set to control the degree to which you want the image deblurred. I've always found this a very useful method. Here's the doc link: deconvlucy

Functional form of 2D interpolation in Matlab

I need to construct an interpolating function from a 2D array of data. The reason I need something that returns an actual function is, that I need to be able to evaluate the function as part of an expression that I need to numerically integrate.
For that reason, "interp2" doesn't cut it: it does not return a function.
I could use "TriScatteredInterp", but that's heavy-weight: my grid is equally spaced (and big); so I don't need the delaunay triangularisation.
Are there any alternatives?
(Apologies for the 'late' answer, but I have some suggestions that might help others if the existing answer doesn't help them)
It's not clear from your question how accurate the resulting function needs to be (or how big, 'big' is), but one approach that you could adopt is to regress the data points that you have using a least-squares or Kalman filter-based method. You'd need to do this with a number of candidate function forms and then choose the one that is 'best', for example by using an measure such as MAE or MSE.
Of course this requires some idea of what the form underlying function could be, but your question isn't clear as to whether you have this kind of information.
Another approach that could work (and requires no knowledge of what the underlying function might be) is the use of the fuzzy transform (F-transform) to generate line segments that provide local approximations to the surface.
The method for this would be:
Define a 2D universe that includes the x and y domains of your input data
Create a 2D fuzzy partition of this universe - chosing partition sizes that give the accuracy you require
Apply the discrete F-transform using your input data to generate fuzzy data points in a 3D fuzzy space
Pass the inverse F-transform as a function handle (along with the fuzzy data points) to your integration function
If you're not familiar with the F-transform then I posted a blog a while ago about how the F-transform can be used as a universal approximator in a 1D case: http://iainism-blogism.blogspot.co.uk/2012/01/fuzzy-wuzzy-was.html
To see the mathematics behind the method and extend it to a multidimensional case then the University of Ostravia has published a PhD thesis that explains its application to various engineering problems and also provides an example of how it is constructed for the case of a 2D universe: http://irafm.osu.cz/f/PhD_theses/Stepnicka.pdf
If you want a function handle, why not define f=#(xi,yi)interp2(X,Y,Z,xi,yi) ?
It might be a little slow, but I think it should work.
If I understand you correctly, you want to perform a surface/line integral of 2-D data. There are ways to do it but maybe not the way you want it. I had the exact same problem and it's annoying! The only way I solved it was using the Surface Fitting Tool (sftool) to create a surface then integrating it.
After you create your fit using the tool (it has a GUI as well), it will generate an sftool object which you can then integrate in (2-D) using quad2d
I also tried your method of using interp2 and got the results (which were similar to the sfobject) but I had no idea how to do a numerical integration (line/surface) with the data. Creating thesfobject and then integrating it was much faster.
It was the first time I do something like this so I confirmed it using a numerically evaluated line integral. According to Stoke's theorem, the surface integral and the line integral should be the same and it did turn out to be the same.
I asked this question in the mathematics stackexchange, wanted to do a line integral of 2-d data, ended up doing a surface integral and then confirming the answer using a line integral!