[java] Subimages based on histogram

Started by
8 comments, last by Mary Coory 18 years, 1 month ago
Hello everbody, I wrote a program that open an image( image that contain text), then draw the histogram of the image. Now I want to split the image into subimages based on the histogram obtained from that image: Here is an example: this is the original image: and this is its histogram: Any idea how to do that? Thanks in advance for any help [Edited by - Mary Coory on March 17, 2006 2:05:08 PM]
Advertisement

No ideas ?
Isn't it better to separate model from view on this matter?

I mean, work with the data you use to render these histograms, and render 'pieces' of it using 'pieces' of the complete data model.

Son Of Cain

(btw, I haven't seen the screenshots, make them clickable using html's < a > tag =)
a.k.a javabeats at yahoo.ca
It'd be helpful to know how you would like subimages to be generated. I'm assuming you want subimages whenever there's a natural blank spot in the histogram.

Perhaps if you were to illustrate how you want your logic to break up the source image we could give you more ideas.
Quote:Original post by Son of Cain
Isn't it better to separate model from view on this matter?

I mean, work with the data you use to render these histograms, and render 'pieces' of it using 'pieces' of the complete data model.

Son Of Cain

(btw, I haven't seen the screenshots, make them clickable using html's < a > tag =)


Hello Son of Cain,

Thanks for your reply, but I really don't get your idea ! Would you please clarify it more ?

Quote:Original post by Funkapotamus
It'd be helpful to know how you would like subimages to be generated. I'm assuming you want subimages whenever there's a natural blank spot in the histogram.

Perhaps if you were to illustrate how you want your logic to break up the source image we could give you more ideas.



Hello Funkapotamus,

Thanks also for your reply. I want to split the original image (text) into subimages each subimage contains one line. Exactly as you said, whenever there's a natural blank spot in the histogram, it will be the spot where should the image be split.

To make more clear

1.suppose this is the original image as before which will the input to my program:

original image

2 . the program will obtain the histogram of the image :

Histogram image

3. the program output the following images ( subimages)







.
.

and so on,

Hope this will help

Thanks
Now that I've seen your logic, please desconsider my previous post ;)
I thought it were related to graphs.

Anyway, the only available input for you is the image file? I mean, can't you access the text that produced the image, in order to split[] it and only then apply "image rendering" on each "token" you get?

Son Of Cain
a.k.a javabeats at yahoo.ca
You've made a histogram, which means you have the histogram available as pure data, not just a graph, right? So scan the histogram for a zero, and remember that row. Keep scanning until you find the next spot that is NOT zero, and remember that row. So what you've done is 'marked' an area with no text in it. You can split the image anywhere in between, for example at the average of those two rows. Once you split off a chunk of the image, start the process over again.

There will be little details along the way, but that's the basic premise you want to use.
Quote:Original post by Son of Cain
Now that I've seen your logic, please desconsider my previous post ;)
I thought it were related to graphs.

Anyway, the only available input for you is the image file? I mean, can't you access the text that produced the image, in order to split[] it and only then apply "image rendering" on each "token" you get?

Son Of Cain


Hello Son Of Cain,

The only way I got the text is via images. I can't access the text as pure data I mean as characters.

Thanks
Quote:Original post by wendigo23
You've made a histogram, which means you have the histogram available as pure data, not just a graph, right? So scan the histogram for a zero, and remember that row. Keep scanning until you find the next spot that is NOT zero, and remember that row. So what you've done is 'marked' an area with no text in it. You can split the image anywhere in between, for example at the average of those two rows. Once you split off a chunk of the image, start the process over again.

There will be little details along the way, but that's the basic premise you want to use.


Thanks wendigo23, your idea sounds good.

Yes I have the pure data of the histogram stored in an integer one-dimension array of zeros and ones.

If I understand your idea, it will be something like that:
int splitPoints [];int j = 0;for (int i=0; i<image.Height; i++)if (hist == 0){ mark1 = i;counter = 0;while( hist == 0) counter++;mark2 = counter;splitPoints[j] =  (mark1+mark2)/2;J++;}


Please help me in building this algorithm

Thanks

This topic is closed to new replies.

Advertisement