Mirroring pixels

• November 16th, 2012, 05:36 PM
lovely92
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.
• November 20th, 2012, 01:10 AM
pmc
Re: Mirroring pixels
If I've understood what you wrote correctly then, using your nomenclature with this particular case, N*H pixels are copied.
• November 20th, 2012, 03:10 AM
pbrockway2
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.
• November 20th, 2012, 03:56 AM
pmc
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.
• November 20th, 2012, 06:06 AM
pbrockway2
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.