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

1. ## 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.

2. ## 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. ## 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. ## Re: Mirroring pixels

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. ## 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.