Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Mirror image in Java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 18-12-2008
Member
 
Join Date: Oct 2008
Posts: 24
Mirror image in Java
  

I am here with a problem in a program having a mirror image in java, that the mirror is half of the picture!
Code:
  public class (pixels 
  public static void main (String [] args) ( 
  Picture img = new Picture ( "E: \ \ fac \ \ ITI \ \ work 2 ITI \ \ coracao_azul.jpg"); 
  int colNum img.getWidth = (); 
  int linNum = img.getHeight (); 
  int a = colNum; 
  int b = linNum; 
 
  for (int c = 0; c <colNum c + +) ( 
  for (int l = 0; l <linNum; k + +) ( 
  Pixel thisP = img.getPixel (c, l); 
 
  img.getPixel (c-1, bl-1). setRed (img.getPixel (c, l). getRed ()); 
  img.getPixel (c-1, bl-1). setGreen (img.getPixel (c, l). getGreen ()); 
  img.getPixel (c-1, bl-1). setBlue (img.getPixel (c, l). getBlue ()); 
  ) 
  ) 
 
 
 
  img.explore (); 
  ) 
  )
I can not figure out where the problem is. Someone let the sight it.

Reply With Quote
  #2  
Old 18-12-2008
Member
 
Join Date: May 2008
Posts: 2,291
Re: Mirror image in Java

I do not understand anything about Java code that you provided (yet) but for what I read in your code, what is happening in a row of pixels is,

Quote:
1 2 3 4 5 6 7 8 9 <- top
1 2 3 4 5 6 7 8 1
1 2 3 4 5 6 7 2 1
1 2 3 4 5 6 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1 <- end
The bold position that the final result shows, the red position where it went for the R, G and B. It takes a position (in red) and replaces another (in bold) for that. One can get confused what is bold or red, but the end result is the same.

What I mean is that you think evil in the algorithm. You should replace the two positions and run the algorithm by half the length of the image.

Quote:
1 2 3 4 5 6 7 8 9 <- top
9 2 3 4 5 6 7 8 1 <- exchanging the top spot with the last
9 8 3 4 5 6 7 2 1 <- change the second position with the penultimate
9 8 7 4 5 6 3 2 1 and so on
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 <- should stop: arrived in the middle
You need a temporary variable that stores the value of the pixel you are going to modify, then as that has the pixel color pixel corresponding to the opposite side, and while you lack: replace the pixel on the side opposite the temporary variable that has pixel value of the original.

I made myself clear?
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Mirror image in Java"
Thread Thread Starter Forum Replies Last Post
Flip or mirror image a photo in Windows Live photo Gallery? Rahul Surya Windows Software 3 04-05-2012 05:23 PM
Need to create a mirror image with windows 7 on hard disk with back up copy $kRITIKa$ Operating Systems 4 27-05-2011 11:26 AM
Apple iPad 2 mirror image to computer The$Tourist Portable Devices 11 29-04-2011 01:50 PM
Segment an image in java Logan 2 Software Development 7 19-04-2010 01:15 AM
GUI image program java Caden Fernandes Software Development 3 12-11-2009 11:48 AM


All times are GMT +5.5. The time now is 02:47 AM.