100*100 -> 2000*2000 with pixel duplication, bug?

M
Posted By
MarcusMoehrmann
Apr 26, 2004
Views
808
Replies
32
Status
Closed
Hello,
I have a psd file with 2 planes (I dont know if this is the correct translation of german "Ebene"), 100*100 pixel. The first plane is left side white, right side black, the second plane is left side transparent, right side black (so the black sides are perfectly same size and position).

Now resize the picture to 2000*2000 with pixel duplication (!). The result is that both black sides are no longer same size ! Bug ?

Regards Marcus

MacBook Pro 16” Mockups 🔥

– in 4 materials (clay versions included)

– 12 scenes

– 48 MacBook Pro 16″ mockups

– 6000 x 4500 px

M
MarcusMoehrmann
Apr 26, 2004
Layer is the correct word!
DP
Daryl_Pritchard
Apr 26, 2004
Hello Marcus,

By "pixel duplication", I think you are referring to "resampling" in the Image Size dialog, correct? How are you identifying the size of the black areas when you compare the sizes for the two layers?

What I find is this:

After resizing the image, I selected the black half of the black/white layer by using the magic wand with a tolerance of 0 and "anti-aliased" unchecked. The result is that a black area of 990 pixels width by 2000 pixels height is selected. Repeating the magic wand selection for the tranparent/black layer, the black area is shown as the expected 1000×2000 pixels in size. So yes, if this reflects a similar approach that you took, then the black half of the black/white layer is 10 pixels smaller in width. Why? I’m not sure.

My first suspicion was that the black/white boundary was interpolated to produce a white-to-black gradient. Zooming in on the image, one will see this has occurred. In fact, if you use the magic wand to first select the black half and then add (Shift+Click) the white half to the selection (picking the color from toward the center of each half), the result will be all but a 20-pixel wide area centered on the boundary has been selected. So, this suggests that there are 20 distinct colors in this area, neither pure white nor pure black.

But…looking at the region under high zoom, the 10 px wide black half of the region appears all the same density of black. Using the eyedropper tool proves this true with RGB = 0/0/0. So, why did the magic wand fail to include this last 10 pixel wide area of black and thus yield the same 1000×2000 pixel area as was selected for the tranparent/black layer? I’m not sure. Regardless, this close inspection does reveal the black area for each layer to be identical in size. Taking this a step farther and using the Color Range tool to select the black area, using a "fuzziness" of 0, that tool did in fact fully select the 1000×2000 pixel black area for each layer.

So, it seems that the method you used for determining the size of your black area will affect the measured values. If using the magic wand tool, I’d say that yes, it does appear to have a bug in how it chooses colors. I can only assume that this "bug" may be inherent in the design of how the magic wand must work in order to support the additional options regarding contiguous/discontiguous selections and aliasing control. It doesn’t strike me as a significant problem, but I’m not sure what you are doing, so that may be a bit presumptive of me.

Regards,

Daryl
L
LenHewitt
Apr 26, 2004
Marcus,

On the layer with B&W, you are bound to get an unsharp edge when scaling up that amount, which you won’t get with the black on transparent layer.
GH
Gernot_Hoffmann
Apr 26, 2004
Len,

I don´t think so. Marcus means Nearest Neighbour by Duplication. NN doesn´t interpolate.
IMO, the effect is a result of the rounding algorithm, which finds the pixel address of the Nearest Neighbour.
What happens at "50" ? An uncertainty of "0.5" appears multiplied by 20 in the destination image.

Best regards –Gernot Hoffmann
L
LenHewitt
Apr 26, 2004
Gernot,

Marcus means Nearest Neighbour by Duplication.<<

Ah, I see. Thank you for clarifying that.
DP
Daryl_Pritchard
Apr 26, 2004
Hmmmm…I hadn’t given consideration to the different resampling techniques, and simply used the Bicubic default. Regardless, I do see for each method that the black area does indeed vary in width when comparing the two layers. As implied by Gernot’s comment, only resampling with Nearest Neighbor gave a non-interpolated result where the black areas were of equal size.
M
MarcusMoehrmann
Apr 26, 2004
Hello all,
yes, I have meant only resampling technique "Pixelwiederholung", i.e. repeating pixels or duplicating pixels, not the bicubic default. Every pixel in the 100*100 should give 20*20 pixel in the resulting image, that’s is my understanding of that technique. When my understanding is right, then the black areas should be equal after resampling.

Regards Marcus
GH
Gernot_Hoffmann
Apr 26, 2004
Marcus,

yes, Pixelwiederholung is the same as Nearest Neighbo(u)r. Is the difference for both black areas 10 pixels ?

By the way – what´s the purpose of this image construction ?

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 26, 2004
Gernot,
no, the difference is only one pixel(row) ! At the layer with transparent the black area starts at X=1000, which is "correct", at the B&W layer the black area starts at X=999, which is one row more than the middle (X is beginning at 0).

The purpose is to create a chessboard with 64 fields, each of size 680*680. So I took a screen photo of the Photoshop transparent "color", saved is as TIFF and read this into Photoshop. The fields in the TIFF are 8*8 pixels in size. When I did an image resize I saw this effect. Okay, maybe there is a better way to get a chessboard, but I am still interested if NN works correctly.

Regards Marcus
DP
Daryl_Pritchard
Apr 26, 2004
Marcus,

I can’t believe how much time I’ve "wasted" today on this, given that I really should be working, but your question has steered me into several puzzling observations with Photoshop, both 7.0 and CS, that I’ve been too determined to keep exploring.

Firstly, I have created a test action that should be performing a set of steps as you describe. Rather than concern myself with the full image in discussion here, the action crops down to a centered 300×150 pixel region and displays it at a high zoom level for viewing the differences between the two layers. I’ve also cut out half of each layer so that the differences can be viewed without toggling between the layers. The action set may be downloaded as <http://jazzdiver.com/photoshop/ResampleTest.atn>, where the action itself is "Half_Fill"

My question for you is are you using PSCS? If so, then I think we are observing the same situation and, oddly, it does not occur in PS7. Using the Half_Fill action, and viewing an even smaller crop of the final image at 800%, I captured a snap of the image in both PS7 and PSCS, then assembled them for comparison as <http://jazzdiver.com/photoshop/Fill_Curiosity.gif>

In both images, the center is marked by the anchor point symbol, illustrating as you mention how the black extends 1 pixel farther into the white area for the white/black layer.

Other things I found puzzling:

1. Referring to the image resulting from execution of the test action, the black/white layer appears indeed to be comprised of pure black adn pure white. However, the transparent/black layer appears to be comprised of a tranparent area, a dark grey, and a pure black. The oddity here is that whether you sample the dark grey or black areas in the image, they all indicate an RGB value of 0/0/0. I wonder why this is? This would not appear to be a question of a 1 pixel discrepancy either, as the dark grey region of the transparent/black layer is 21 pixels wide. This seems very strange to me.

2. In originally creating my action, I found the initial results were different from what is now obtained. Why? Because even though I filled a precisely selected area (50×100) with Black (0/0/0), the full area was not truly all a pure black. In order to obtain a true black throughout the area, I had to fill it 5 times total! This involved first filling from the center of the selected area, and then moving the fill cursor out to each of the left and right edges of the area until new values of 15/15/15 and 1/1/1 were found, and reapplying the fill. I’m going to post a new topic about this particular issue, since it warrants seaparate discussion. The behavior was the same in both PS7 and PSCS. Note also that my Fill tool was set for a 0 tolerance and was unaffected by aliasing settings.

So, from all this, I can only suggest that in addition to your current observations, there may be a factor as well regarding whether or not you are obtaining a truly solid fill of one color as you desire.

Isn’t is curious how the simplest behaviors can lead to such oddities?

Regards,

Daryl
L
LenHewitt
Apr 26, 2004
Markus,

When you created your selection area, did you have anti-alias selected for your marquee?
DP
Daryl_Pritchard
Apr 26, 2004
Hmmm…Len, why did I think you might show up here with that comment? Ha!

So, for others reading my prior message, Len’s correction of my need to have anti-aliasing selected did indeed resolve my 2nd issue above. I’ve now edited the test action accordingly and re-uploaded it.

The 1st question remains unaffected.

Regards,

Daryl
M
MarcusMoehrmann
Apr 26, 2004
Hello Daryl,
first short answer for now (i will look at your examples later): yes Photoshop CS.

Len: I use a fix size of 50*100 for my black rectangle. I use a border of 0 Px, so I think this is no anti-alias.

BTW, when I resize to 200*200, the effect is not shown and both black areas are 100*200 as expected !

Regards Marcus
M
MarcusMoehrmann
Apr 26, 2004
Addition for Len: my black is 100% in an greyscale/8 picture and the B&W border is exact (0% left (white) pixel row, 100% right (black) row).

Regards Marcus
DP
Daryl_Pritchard
Apr 26, 2004
Marcus,

I’m using the same fixed 50×100 size for selection of my black rectangle in my test action, BUT that selection is established via a Select All and then a Transform Selection. I didn’t think of using the Fixed Size since it didn’t provide for a reference point. When I did instead use the Marquee Tool, the difference after the fill was applied was that I did in fact obtain a 100% solid fill from edge to edge. Oddly, that does not happen when the transformed selection is used.

Going in and revising my test action to use a Fixed Size selection had the end result of removing the dark gray areas that had puzzled me before. Curiously, I discovered along the way that the gray and black areas previously seen to be measured as the same 0/0/0 had reappeared but as two values. So, somewhere I did something wrong it seems, as measuring two distinct values for two visually different colors makes much more sense. Apologies for any confusion that might have added to this discussion.

Now it seems all my "thinking aloud" has brought me full circle back to the simplicity of Marcus’s question…and seeing the same result even when a fill with anti-aliasing is used. That is, the image resizing affects the black/white layer in such manner as to "spill over" a 1-px column of black, creating a 1001-px wide black area and 999-px wide white area.

Regards,

Daryl
GH
Gernot_Hoffmann
Apr 27, 2004
Marcus,

if you want merely a chessboard then you can get
an EPS, directly programmed by PostScript.

Just specify the size in millimeters.
This would be a vector file without any pixels
unless it´s rastered.

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 27, 2004
Hi Gernot,
not merely, the ChessBoard will go into a PhotoShop Image and is partly hidden and rotated by 45 degree (and some other minimal transformations to let it fit).

My workaround was to resize a chessbord with 10*10 fields and cut away the surplus afterwards.

Regards Marcus

PS I now initiated a Problem Report at Adobe Support.
GH
Gernot_Hoffmann
Apr 27, 2004
Marcus,

I didn´t read the whole thread, but perhaps you thought the first pixel is No.1 . It´s No.0 as everywhere in image processing.

50×100 color pixels placed in a transparent 100×100 pixel image, snapped to left boundary.
Blown up by nearest neighbour to 1000×1000 pixels.
The color pixels count from 0 to 499. The histogram says: 50% covered.

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 28, 2004
Hi Gernot,
I know that pixels starting at 0.
please read my message #9 of 18, the B&W is not correct (and blow up to 2000*2000).

Regards Marcus
GH
Gernot_Hoffmann
Apr 29, 2004
Marcus,

sorry, I see you were counting from X=0.
Did you use View Actual Pixels or View 50% ?

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 29, 2004
Hi Gernot,

I zoomed in to the maximum and could see exactly the B&W border, and if you switch between the layers, you see the discrepancy.

Regards Marcus
PG
Per_Ganz
Apr 29, 2004
I think, the problem is that you are apparently unaware how the selection tools work and that is where the problem already is created. To create transparency in your second layer you have to select the white area. The most obvious choice as a tool is the magic wand. If you use this, the tolerance in the options bar is automatically set to 32, which creates a feathering effect. set the tolerance to 0 and untick the anti-aliased (in german: glaetten) option. Then select your white area, delete it and do all the rest. It will work. It is not always a bug when you just do not know how to handle a tool.
Per
M
MarcusMoehrmann
Apr 29, 2004
Hello Per,
I have done it again with other tools and the same result: I had a white 100*100, made a rectangle 50*100, filled it black, had a second transparency layer, made a rectangle 50*100, filled it black. Thats the source. If you enhance the picture to 2000*2000, you have the white area a little smaller than the black area.
It has nothing to do with tools etc.
Regards Marcus
PS if you want I can send you my psd file per mail, the 100*100 source. You can mail me your address at
DP
Daryl_Pritchard
Apr 29, 2004
Hi Per,

Marcus is correct in his observations. Taking a slightly different approach from he, I obtain the same results as you can observe if you download and execute my test action <http://jazzdiver.com/photoshop/ResampleTest.atn> which ultimately crops down to view only a small central area of the 2000×2000 px image.

Or, yet another approach is to do the following:

1. Create the 100×100 px new image in white
2. Using the Fixed Size selection of 50×100 px for the Marquee tool, click at the top right of the image so as to select the right half.
3. Fill the selected area with black, noting that the selection is still active.
4. Select Copy as a Layer, which will create a tranparent layer that duplicates the black half.
5. Now, reselect the original background layer in the palette and double-click to promote it to a floating layer.
6. Change to the Move tool and Shift+DownArrow a few times to shift the layer down vertically by several pixels.
7. Change to the Zoom tool and zoom in on the intersection of the black/white/transparent regions. Note that the borders are all currently sharp and each region is of the same size.
8. Now, resize the image to 2000×2000 px with Nearest Neighbor resampling.
9. Zoom out to bring the same intersection of b/w/t into view, then zoom in again on that area. This will illustrate that an error has been introduced whereby the black has been resized 1 pixel wider for the b/w layer than the b/t layer, and that – as Marcus stated – the white area is now correspondingly smaller.

Here’s a comparison before and after the resampling that illustrates the error: <http://jazzdiver.com/photoshop/nn_resample_error.gif>

Regards,

Daryl
L
LenHewitt
Apr 30, 2004
Daryl,

Looking at this from a purely logic p.o.v. as a mental exercise I *think* I can understand why it is happening.

When the black area is on a transparent layer, it has no ‘nearest neighbour’ on the transparent boundary. When it is on the white b/ground it does have a nearest neighbour at that boundary. Note: I’m not saying that the operation is correct, and without intimately knowing the algorithm used this is largely guesswork. I’m merely attempting to think of an explanation for the difference.
GH
Gernot_Hoffmann
Apr 30, 2004
Len,

an interesting academic discussion. My test (#18)
had shown correct results for color on transparent.
It´s hardly different for 1000 pixels (my test)
compared to 2000 pixels (OP´s test).
But I didn´t use the rectangular marquee, I had created the color area created separately, copy and paste.

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 30, 2004
Hi Gernot,
it is different, the error is shown at 2000 pixels, not at 1000 pixels ! Regards Marcus
DP
Daryl_Pritchard
Apr 30, 2004
Len,

Your analysis of the situtaion sounds "dead-on" to me. It not what I think most of us would expect to see occur, but when you understand what resampling means, then the outcome here does make sense. Of course, a 1 pixel "error" (not exactly an error I suppose) will be indistinguishable when the image is viewed at 100%.

Daryl
GH
Gernot_Hoffmann
Apr 30, 2004
Again the test (and why this rather useless effort):

I´m able to create an image 100×100, half color
half white (or transparent), able to upsample for
2000×2000 by Nearest Neighbour.
But I´m not able to reproduce the reported bug.
I found Color 0..999, White 1000..1999.

I had even tried to mimic this rather odd two-layer
construction. Even then it´s OK (PhS 7).

I wouldn´t bother about a 1 pixel error but I found
it interesting whether there might be a round-off
error in NN. Not to blame PhS, only because I had
programmed interpolations before.

IMO, neither an axis aligned nor a rotated chess
board should be drawn by a raster image processing
program, if accuracy is important.

This leads me to another perhaps interesting issue
(experts know this already):
A PATH is filled in PhS by pixels. Without feathering/
anti-aliasing the path is not filled completely.
The path is a vector path (accuarate) but the content
has only source image resolution. There are always frag- ments of unfilled pixels at the path boundary.
A vector program would fill the path with destination
device resolution (e.g. solid color assumed,for simplicity).

This leads me to the conclusion, that a rotated chess
board (as mentioned by Marcus) should be designed ONLY
by a vector program. The same is true for logos with
solid color areas.
Don´t use PhS for such an application. If the path
should have been designed in PhS, then export the path
for Illustrator and proceed there or by direct PostScript programming.

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 30, 2004
Hello Gernot,
I use Photoshop CS and there it happens.

This was my choice to make a chessboard and put in in a bigger image (image reconstruction, the originalchessboard was bad). Maybe via vector is would be a better choice, but I just bought Photoshop for this reconstruction and found this out by experimenting.

And I found it worth to discuss, because I wanted to know if my understanding of resampling (by NN) is correct. If my understanding is okay, then a program like Photoshop should work correctly or "as expected".

Regards Marcus
GH
Gernot_Hoffmann
Apr 30, 2004
Marcus,

the discussion is OK, but if you want to rotate the
chess board pattern, then you should check "Bicubic" (I heard there are now several versions in CS…).

And all of a sudden the discussion about a 1-pixel
bug or "bug" is obsolete, because sharp edges cannot be retained in rotated raster images.

Best regards –Gernot Hoffmann
M
MarcusMoehrmann
Apr 30, 2004
Hi Gernot,
you want to catch me !

I wanted to start with a board with EXACTLY 680*680 pixel fields before rotation (of course nobody can see the difference in the destination 10.000*12.000 pixel image). But my impression was that "something is not correct".

Regards Marcus

Must-have mockup pack for every graphic designer 🔥🔥🔥

Easy-to-use drag-n-drop Photoshop scene creator with more than 2800 items.

Related Discussion Topics

Nice and short text about related topics in discussion sections