hallo, i have to do programming on freeman chain code to traces the pixels of signatures. I usd bitmap image which in black and white. Can someone help me on how to do it in java?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
hallo, i have to do programming on freeman chain code to traces the pixels of signatures. I usd bitmap image which in black and white. Can someone help me on how to do it in java?
What have you tried? Where are you stuck?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
i didn't try anything yet, because i not have any idea about chain code in java. i need someone to give me idea on doing this.
Describe the algorithm that you are trying to code in more specific terms.
To get at the pixels in an image there is the getPixel methods for example.
You mean you didn't even try a web search? We have no clue where you are stuck - the algorithm, reading images, java in general...the question is vague enough to have so many different answers you are not helping yourself receive the help you wish.i didn't try anything yet, because i not have any idea about chain code in java. i need someone to give me idea on doing this.
okay. it is like this.
i have a signature that i get from a tablet, then i need to trace all the pixels of the signature using the chain code algorithm. the chain have 8 connection, which is from number 0-7. and i need to get the code which can trace pixels that have junctions.
i have found some codes from internet. but more in matlab, or in C/c#, so i need help, on how doing it in java.
If you have an image in a BufferedImage object you can look at its pixels by using the getRGB method.
None of the terms you are using (signature, tablet, chain code, 8 connection, junctions) to describe your problem relate to java programming. If you have a design or algorithm that you need help with you will have to post the steps in it that you need help with to write the program in the java language.
i have run this program,
import javax.imageio.ImageIO; import java.io.*; import java.io.IOException; import java.awt.image.BufferedImage; import java.util.Vector; public class Imagersteg { static Vector<Integer> checkx = new Vector<Integer>(); static Vector<Integer> checky = new Vector<Integer>(); static Vector<Integer> direct = new Vector<Integer>(); public static void main( String[] args ) throws IOException{ BufferedImage image = null; File imagefile = new File("C\\Users\\INTAN\\sign.bmp"); image = ImageIO.read(imagefile); int w=image.getWidth(); int h=image.getHeight(); int x, y; x = y = 0; boolean flag = false; for(int k=0;k<h;k++) { for(int j=0;j<w;j++) { int rgbValue= image.getRGB( j, k) + 0xFFFFFF + 1; if(rgbValue == 0) { x = j; y = k; flag = true; break; } } if(flag) break; } System.out.println("Success"); System.out.println( x + " " + y); int[] lx = new int[8]; int[] ly = new int[8]; lx[0] = 0; lx[1] = 1; lx[2] = 1; lx[3] = 1; lx[4] = 0; lx[5] = -1; lx[6] = -1; lx[7] = -1; ly[0] = -1; ly[1] = -1; ly[2] = 0; ly[3] = 1; ly[4] = 1; ly[5] = 1; ly[6] = 0; ly[7] = -1; int l = 0; int a = 0; int b = 0; int beforex = 0; int beforey = 0; boolean flagz = false; for(int j = 0; j < 500; j++) { if(flagz) break; for (int i = 0; i < 8; i++) { if(check(x + lx[i],y + ly[i]) && !((x + lx[i] == beforex) && (y + ly[i] == beforey))) //if(!((x + lx[i] == beforex) && (y + ly[i] == beforey))) { if((image.getRGB(x + lx[i], y + ly[i]) == -16777216)) { l = i; a = x + lx[i]; b = y + ly[i]; checkx.add(x); checky.add(y); beforex = x; beforey = y; x = a; y = b; break; } checkx.add(x); checky.add(y); } if(i == 7) flagz = true; } System.out.println(x + " " + y + " = " + l); direct.add(l); } Integer[] chain= new Integer[direct.size()]; direct.copyInto(chain); for(int i = 0; i < chain.length; i++) { System.out.println( "chaincode = " + chain[i]); } int count = 0; for(int i = 0; (i + 2) < chain.length; i= i+2) //direction in array { for(int j = 0; j < 8; j++) //direction 0 to 7 { if(chain[i] == j) //if 2nd pixel = i { if(chain[i+1] == j+1 || chain[i+1] == j-1) //if (3rd pixel = i+1) || (3rd pixel = i-1) { count++; } } } } System.out.println("total input =" + count); } public static boolean check(int x, int y){ Integer[] xed= new Integer[checkx.size()]; Integer[] yed= new Integer[checky.size()]; checkx.copyInto(xed); checky.copyInto(yed); for( int i = 0; i < xed.length; i++) { //System.out.println(x + " . " + xed[i] + " . " + y + " . " + yed[i]); if((x == xed[i]) && (y == yed[i])){ //System.out.println(x + " . " + xed[i] + " . " + y + " . " + yed[i]); return false; } } return true; } }
But i have got error, why?blabla.jpg
Last edited by aelynne; February 23rd, 2012 at 03:45 PM.
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
The program can not find the file. Make sure the file is located where the program is looking for it.
Please post text instead of an image. It is not possible to copy and paste from an image.
To copy the contents of the command prompt window:
Click on Icon in upper left corner
Select Edit
Select 'Select All' - The selection will show
Click in upper left again
Select Edit and click 'Copy'
Paste here.
its okay, i have successed. but, this program only for straightforward signature, doesn't have any junction. If the signature is complex with junction, how to do that?
Can you ask your questions in java programming terms?
The words you are using have no meaning when talking about a java program: signature and junction.
These words relate to your problem, not how to code a program.
i have a chain code coding for straight-forward signature,and now i need to do for the signature that have intersection, how?
Can you ask your questions in java programming terms?
The words you are using have no meaning when talking about a java program: signature, chain code and intersection
These words relate to your problem, not how to code a program.
That isn't how this works. You're essentially saying, "You finished your homework, and I haven't, so can I see yours?". Make your own attempt, then post a specific question along with an SSCCE if you get stuck.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!