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.

Results 1 to 5 of 5

Thread: Mirroring pixels

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    My Mood
    Cheerful
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mirroring pixels

    Mirroring is done by copying. Suppose a Picture has H rows of Pixels and W columns of Pixels and W is an even number, like W is 2N. Here N is a the whole number that is exactly 1/2 of W. How many Pixels are copied when the Picture is mirrored along the vertical line through its middle?
    I am completely lost.
    Can anyone please help me.


  2. #2
    Junior Member pmc's Avatar
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mirroring pixels

    If I've understood what you wrote correctly then, using your nomenclature with this particular case, N*H pixels are copied.

  3. #3
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Mirroring pixels

    Make yourself a small image - say 4 rows each with 6 elements. Make it out of 24 small squares of paper (mark or colour them so they can be easily identified).

    Now reflect the image: that is, move each small square element to its mirror image position. But you can't ever have two elements at the same position so I would think you will need a temporary position to which the small elements can be moved. Then it's a matter of counting the moves you have to make - each move is a copy.

    I assume you are supposed to do this as efficiently as possible. I can't see how as few as N*W moves could do the job without losing 1/2 the picture.

  4. #4
    Junior Member pmc's Avatar
    Join Date
    Nov 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mirroring pixels

    Quote Originally Posted by pbrockway2
    I can't see how as few as N*W moves could do the job without losing 1/2 the picture.
    True, half the picture would be lost with N*H copies and that may be undesirable depending on the requirements (which weren't specified) but, mathematically speaking, that's the smallest required number of pixels to copy to achieve the mirroring.

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Mirroring pixels

    iOh, I see! I hadn't considered that the OP might be trying to create a symetrical picture from one half...

    In that case, and considering we're in the OOP forum, I suggest that it be done with zero copies.

Similar Threads

  1. Getting pixels from an image, and saving them in an array?
    By jtvd78 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: April 14th, 2011, 08:48 PM
  2. [SOLVED] Coloring Pixels
    By Javajava in forum Java SE APIs
    Replies: 2
    Last Post: July 7th, 2010, 04:02 PM
  3. Obtaining straightline pixels
    By base2coder in forum Java Theory & Questions
    Replies: 4
    Last Post: September 11th, 2009, 01:58 AM