Member Avatar for iamthwee

Ok,

Here is wat i gotta do in my next assinement.

I am given a file, either a bmp or jpeg containing a picture (at the moment it's either one or the other), I'm not sure.

The file contains a word of five letters from the alphabet. All these words are block capitals.

I have to somehow, write a program to read the file and establish what letters they are! My teacher said as a hint, I will have to use some sort of learning network to intelligently distinguish what letters are being shown. Since the letters are of a generic typeset rather than handwritten crap, she said it shud b easier.

I have an idea as to which learning algo I wud like to use and what data structure I'd like to represent it with. However, I have no idea how to do the scanning of the file.

Please help!! :cry: :cry: :cry:

Such post was not at all expected from you....At first look I said what a ******* post. You almost made me blind.
I swear I would have given you a bad rep for this...but you are lucky as I recently gave a positive rep and can't add more.

Member Avatar for iamthwee

Oopsy I pressed da wrong button it shud be this...

Ok,

Here is wat i gotta do in my next assinement.

I am given a file, either a bmp or jpeg containing a picture (at the moment it's either one or the other), I'm not sure.

The file contains a word of five letters from the alphabet. All these words are block capitals.

I have to somehow, write a program to read the file and establish what letters they are! My teacher said as a hint, I will have to use some sort of learning network to intelligently distinguish what letters are being shown. Since the letters are of a generic typeset rather than handwritten crap, she said it shud b easier.

I have an idea as to which learning algo I wud like to use and what data structure I'd like to represent it with. However, I have no idea how to do the scanning of the file.

Please help!! :cry: :cry:

Ps. the reason why you are going blind is not because of my post. It's because of the other thing... :cheesy:

commented: learn how to write english +0

she said it shud b easier.

I doubt she said that, teachers are not known for using crappy text messaging shorthand when speaking to their pupils.

Here is wat i gotta do in my next assinement.

So go out and do it. By just posting it here and waiting for someone to do it for you you're not going to learn anything, and we're not going to do it for you and get a lazy know-nothing as a future colleague who only passed his exams through cheating.

Member Avatar for iamthwee

I doubt she said that, teachers are not known for using crappy text messaging shorthand when speaking to their pupils.

So go out and do it. By just posting it here and waiting for someone to do it for you you're not going to learn anything, and we're not going to do it for you and get a lazy know-nothing as a future colleague who only passed his exams through cheating.

Hello, I know how to do the rest. Well I think I do, it's quite a difficult assignment. However, I was just wondering how do I get it to recognise letters in a bmp file? Have you or anyone else done something similiar.

Sorrie for writing in text speak. Sometimes I forget that not everyone likes that, all my friends use it though. :o

your teacher was quite clear. You're going to have to use a piece of artificial intelligence and probably genetic algorithms.
Recognising letters in a bitmap is a standard example of that and explained in quite a few tutorials about neural nets and genetic algorithms.
If you have an assignment at that level you should be able to do your research and will have had classes explaining what those are and how to write them.

Member Avatar for iamthwee

your teacher was quite clear. You're going to have to use a piece of artificial intelligence and probably genetic algorithms.
Recognising letters in a bitmap is a standard example of that and explained in quite a few tutorials about neural nets and genetic algorithms.
If you have an assignment at that level you should be able to do your research and will have had classes explaining what those are and how to write them.

No we haven't had any classes about that, I'm not even uni yet... that's another two years away, he he. It's not looking good for my teacher is it? :o

I will look into what you said. Tell me would it be easier to read it as a jpeg file or a bmp file?

Thank you for all you help so far.

reading BMP is easier to implement as it's a non-compressed format.
But for Java there may well be readymade libraries to read JPEG where BMP support is likely lacking.
See http://www.wotsit.org for file format descriptions (many of them with sample code in usually C).

Hi iamthwee,

The problem of classifying image files according to what's inside them falls into the general category of "supervised learning problems." To see how to solve these kinds of problems, let's consider a very simple example:

Suppose I give you a thousand images in separate image files. Each image is a 50x50 bitmap grid, and each pixel in these grids is either black or white - no color and no shades of gray.

I tell you that each image is an image of either a "1" or a "0." Your job is to figure out which images are which, without doing too much work by hand.

If all the "0" files looked exactly alike, with the exact same pixel pattern in each file, then this problem would be trivially easy! Unfortunately, each "0" file is a little different. In some, the "0" has a smudge in the corner. In others, the "0" has a bit of a tail coming off the top. In others, there are speckles (artifacts from the scanner) at the bottom. The same thing is true of the "1" files - each is a little different. A human being, of course, can look at these files and know which is which, but how can a computer?

Here's an idea. Even though there are slight differences between each "0" image file, there are sets of "core pixels" which are roughly the same (always black or always white) in each. How can we capture whether a pixel is "core" or not? We could classify 50 images by hand (into either the "0" group or the "1" group), then construct a statistical profile for each group. By "statistical profile" I mean this: each image is a 50x50 grid, right? So it's really just an array of length 2500. A statistical profile is an array of 2500 frequencies, which tell you how often that pixel is black in the manually-classified images.

In other words, you would take all the "1" images you classified by hand - let's say there are 21 - then for each pixel you would calculate how many times (out of 21) that pixel is black. The resulting list of frequencies is your statistical profile. You can do the same thing for the 29 "0" images you classified by hand.

Now, to determine whether one of the unknown images (the other 950 that we didn't look at, remember) is a "0" or a "1", calculate the probability that it is a "0" and the probability that it is a "1," then classify it according to whichever probability is bigger. By "calculate the probability" I mean something like this:

double running_probability = 1;
for (int i = 0; i < 2500; i++) {
     if (image_pixels[i] == "black")
          running_probability *= profile[i];
     else
          running_probability *= (1-profile[i]);
}

Basically, you keep a running product of the likelihood of seeing the unknown image's pixels given the profile.

This is one way of doing it. Your problem is a little more difficult than our simple example (you have to take position shifts into account, your alphabet is bigger than "0" and "1", you're dealing with five characters per file, which means you have to effectively break the file into smaller image-windows, you probably have to deal with shades of gray, etc). But I will leave all of that stuff to you - it is also detailed in numerous machine learning tutorials online.

Now, please take stock of what we're doing here - we're looking at a small sample of the data, classifying it by hand, then "discovering" features of the data (pixel frequencies) which will let us classify unknown data automatically. This is the essence of supervised learning.

As jwenting said, there are other ways of solving this problem. I'm not sure that I would bother with genetic algorithms (I find the subject absurdly complicated) but neural nets are fairly easy to grok and are definitely big right now, meaning that if you learn them you will probably find some use for them somewhere down the road. The way I have proposed to solve your problem is kind of naive, and was really only supposed to illustrate the principles behind supervised learning - I recommend that you browse the net (even if you have no further interest in this stuff, just to give you a sense of other approaches to the problem). If you want a good text and you already understand linear algebra and multivariable calculus, I can recommend Hastie, Tibshirani, and Friedman's The Elements of Statistical Learning:

Amazon link

Good luck!

commented: Good:sunny +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.