Results 1 to 3 of 3
  1. #1
    syarizma is offline Member
    Join Date
    Aug 2009
    Posts
    21
    Rep Power
    0

    Cool still problem with image processing

    please everybody,i really need ur help to solve may problem again..
    i'm already done the program of converting an image to binary using applet( Binary_Image)..now, i do second step of the character segmentation using the Hough Transform approach..But i did not know how to call the image in binary to the Hough transform program(HoughTransfrom1 ).

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.image.*;
    import java.awt.Image.*;
    
    
    
    public class Binary_Image extends JApplet{
     
        	Image img;
        	int iw,ih;
        	int pixels[];
        	int cnt1=0,cnt=0,cnt2=0;
        	
        	public void init()
            {
            	try
                	{
                	
                	ImageIcon imageIcon = new ImageIcon("jawi.gif");
                	Image img = imageIcon.getImage();
                		
                		iw = img.getWidth(null);
                		ih = img.getHeight(null);
                		
                		pixels = new int[iw*ih];
                		PixelGrabber pg = new PixelGrabber(img,0,0,iw,ih,pixels,0,iw);
                		pg.grabPixels();
     
                	} catch(InterruptedException e) {};
                
                	for(int i=0;i<iw*ih;i++)
                    {
                    	int p = pixels[i];
                    	int r = (p>>16) & 0xff;
                    	int g = (p>>8) & 0xff;
                    	int b = (p) & 0xff;
                    	int k = (int)(.56*g + .33*r + .11 * b);
                    
                    	cnt++;
                    			if(k<36)
                        			{
                        				cnt1++;
                        				pixels[i]=(255 << 24)|(0 << 16)|(0 << 8)|0;
                        			}
                        			else
                            			{
                            				cnt2++;
                            				pixels[i]=(255 << 24)|(255 << 16)|(255 << 8)|255;
                            			}
                            		}	
                            		//System.out.println("Total no of pixels ="+cnt);
                            		System.out.println("Total no of black pixels ="+cnt1);
                            		//System.out.println("Total no of white pixels ="+cnt2);
                            
                            		img = createImage(new MemoryImageSource(iw,ih,pixels,0,iw));
                                    //double [][]ImgArr =new double[50][50] ;        
        }
        
        public static void main(String[]args) 
        	{
        		JFrame frame = new JFrame ();
        		
        		Binary_Image applet = new Binary_Image();
        		
        		frame.add(applet,BorderLayout.CENTER);
        		
        		applet.init();
        		
        		frame.setSize(500,300);
        		frame.setLocationRelativeTo(null);
        		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        		frame.setVisible(false);
          }   
    }
    Java Code:
    public class HoughTransfrom1 {
    		
    			   
    			int i,j,Om;
        	 	double thetamin;
        	 	double sinTh;
        	 	double cosTh;
        	 	int r;
        	 	
        	 	//double rhomax,thetamax,CONV,RHOMAX;
        	 	
        	 	double rhomax=50;
        	 	double thetamax=180;
        	 	double CONV=30;
        	 	
     //   	 	public static void main(String[]args)
     //	  	 	{
        	 		void rho_theta_hough_transform()
        	 			{
       						double [][]Tr2_Acc_Array =new double[50][50] ;
        	 				//double [][]ImgArr =new double[50][50] ;
        	 	
        	 	
        	 	/*rho-theta Accumulator Array initializer*/
        	 	for (i=0;i<rhomax;i++)
        	 	
        	 		for(j=0;j<thetamax;j++)
        	 			
        	 			Tr2_Acc_Array[i][j] = 0;
        	 			
        	 			
        	 			for(i=0;i<50;i++)
        	 			{
        	 					for(j=0;j<50;j++)
        	 					{
        	 						/* input image Array*/
        	 						if (ImgArr[i][j] ==1)
        	 						{
        	 							for (Om=0;Om<rhomax;Om++)
        	 							{
        	 								
        	 								thetamin = Math.PI / thetamax;
        	 								
        	 								sinTh = Math.sin(thetamin);
        	 								cosTh = Math.cos(thetamin);
        	 							
        	 								
        	 							
        	 								r = (int)(i*cosTh + j*sinTh);
        	 								if(r<0)
        	 									r= Math.abs(r);
        	 								
        	 									/*Add into the Acculumator Array */
        	 										Tr2_Acc_Array[Om][r]+= 1;
        	 									
        	 							}
        	 	
        	 						}
        	 					}
        	 			
        	 			}
        	 }
    
    
        	 
        	 void rho_theta_print_Arr()
    		{	
    			int i,j ;
    			double sinTheta , cosTheta ;
    			double MIDDLETH,RHOMAX;
    		
    			
    			double [][]Tr2_Acc_Ary = new double[50][50] ;
        	 	double [][]ImgArr = new double[50][50] ;
        	 	
        	 	
    			
    			System.out.println( " ---- p(rho) = x cos theta + y sin theta ------ \n" );
    			
    			for ( i = 0 ; i < rhomax ; i ++ )
    				{
    					for ( j = 0 ; j < RHOMAX ; j ++ )
    					{
    							if ( Tr2_Acc_Ary[i][j] >= threshold_rho_theta )
    						{
    							if ( i == 0 )
    							{
    								System.out.println( " Vertical line Rho is:"+ j );
    								continue ;
    							}
    							if ( i == 0 )
    							{
    								System.out.println( " 2 y"+" ="+ ( (cosTheta / sinTheta ) * -1)+"x" + ( j / sinTheta ) ) ;
    							}
    							else
    							{
    								System.out.println( " 3 y"+" ="+ ( (cosTheta / sinTheta ) * -1)+"x" + ( - (j-MIDDLETH) / sinTheta ));
    							}
    						}
    					}
    				}
    			System.out.println( " Maxima:", max_acc_num );
    			System.out.println( " ---- p(rho) = x cos theta + y sin theta end ------ \n" );
    		}
    		
    }

  2. #2
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default Re: still problem with image processing

    hi,
    i am doing a project on character segmentation.plz mail me if u have any info and code.


    thanks.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default Re: still problem with image processing

    Please don't resurrect old threads but start your own. I'm closing this one.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Image processing
    By syarizma in forum Advanced Java
    Replies: 6
    Last Post: 08-17-2009, 05:15 AM
  2. Processing an Image with csimage
    By coldfire in forum New To Java
    Replies: 2
    Last Post: 01-27-2009, 08:21 AM
  3. Image Processing
    By Josh_FL in forum Advanced Java
    Replies: 4
    Last Post: 12-30-2008, 02:45 AM
  4. image processing
    By sathish natrajan in forum Java 2D
    Replies: 2
    Last Post: 11-06-2008, 05:13 PM
  5. Image Processing in J2ME
    By mobeenkhan in forum CLDC and MIDP
    Replies: 1
    Last Post: 08-02-2007, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •