Technical Slop

Navigation

Table of
Contents

Displace
Considerations
Solid
Channels
Circle Grads
Gradients
PSD
Curve It
Tweakables
Scans
Broken China
Bulge
Math 1
Math 2
Heat Waves
Reflection Maps
Power Distort

Other
Cannify
Extrude
Whispies
AMP
Brush Making
Picking Colours
13 Revisited
Levels
Pixel Shuffle
UVW 2
Pui Pui
Light Rig

E-Mail

AMP

I was poking around one day. I was looking for some arcane PS material for lateral thinking. This had to do with some things about Curves that I'm not entirely happy with. As things go, I was struck by the memory of Moiré Removal by Kai (See also: Kai's Power Tips). Half of the puzzle fell in to place. I suddenly had the tool, I just had to learn how to use it better, with real precision.

-Enter AMP files. When you use Curves, there are two kinds of Curves: the smooth kind and not-smooth kind. We will be dealing with the not-smooth kind, AKA Arbitrary. See that little pencil? Clicking that puts Curves into not-smooth mode.

I don't know if you've noticed or not, but you can save curves for later retrieval with the Curves dialogue. "Load" and "Save" are right there. If you save a smooth curve, the extension is ACV. If you save a not-smooth curve (arbitrary), the extension is AMP.

AMP curves and their files are what interest me. So I started poking around with them. Enter a hex editor.

Ah... here we go.

 

-

 

Pretty damn spiffy. A screen capture not showing the whole story, but it shows enough. I even tossed in a red line as a break showing an important data division in the AMP file.

So what's the deal? If I showed you the whole thing, you would notice a pattern. The data is divided into chunks of 256 bytes. In the above, the first chunk starts at line 000h and ends at 0f0h. Notice how the bytes in that range go from #00 - #FF, or 0 - 255. That chunk set is a straight line in the Curves dialogue going from corner to corner.

Each chunk represents a channel in the Curves dialogue. But things get a bit weird around this. The number of channel chunks depends on the mode (RGB, CMYK, etc.) and the modifications made. From here on out, just RGB.

Run Curves and put it in arbitrary mode. Don't make any modifications at all to *any* channel. Click "Save" and save it. If you then open the resulting AMP file in a hex editor, there will be 3 channel chunks, one for each R, G, and B channels. Kind of makes sense, don't it?

Now, in the Curves dialogue, you can make changes to RGB, R, G, and B using the pull-down menu. If you make changes to R, G, or B, but not RGB, the AMP file will still have 3 channel chunks. Still makes sense, don't it? Here, it goes something like this:

Pull-down Range  
RGB no range / unmodified Collective RGB
R 000h - 0f0h Red channel
G 100h - 1f0h Green channel
B 200h - 2f0h Blue channel

This is where things get weird. If you make any changes to RGB, then you will end up with 5 channel chunks, which is mostly understandable. It goes like this:

Pull-down Range  
RGB 00h - 0f0h Collective RGB
R 100h - 1f0h Red channel
G 200h - 2f0h Green channel
B 300h - 3f0h Blue channel
??? 400h - 4f0h ???

For some reason there is an extra channel chunk at the bottom. I don't know what it's for; I don't know what it does. But I do know that it's necessary for the AMP file to load. I suspect it has something to do with Transfer Function files (ATF), which has something to do with print, but I don't know.

I've tested the above anomaly rather extensively in RGB mode and that's how it works for me. I did some testing with CMYK, but not a lot, and the pattern seems consistent.

If it's a Greyscale AMP file, one channel, then there is only one channel chunk. Cool beans for that.

Well, that's enough of that. Let's move on and revisit Kai's work with the above information tossed in.

 

-A simple greyscale image will do. Oh, like the one on the left.

I tried coming up with a Moiré problem scan, but it just wasn't working. So I decided to fake it.

I took a chunk of page from a magazine, lightly folded it, and scanned it in. It will serve.

 

-Make a selection of the Moiré problem area. Make it a decent selection. Get a lot of it (the Moiré) in there, but don't contaminate the selection with parts of the photo you don't want to curve.

-Image > Histogram. How often do you see this in a tutorial? Hehe.

The idea is to get the brightness range in the selection. This will tell us where to modify in the AMP file.

I started with the cursor on the left, and slowly moved it to the right until Count was above 0. This is to get the bottom brightness value of the selection.

Then I held the mouse button down to make a selection. I moved it until Percentile was 100%. I even moved the cursor around to make sure that I had 100% without selecting more than I had to. I want the selection to end exactly where the Percentile hits 100%

There is my range in Level. The range is 39 - 97. Sounds good to me.

You might even use Levels to get a range.

 

I hit Curves to get an AMP file template. Run Curves (ctrl + m), put in Arbitrary mode, click Save, and saved it. Since this is Greyscale, the there is only 1 channel chunk. Get out of Curves.

Time for some hex editing on the AMP file. Open it up in hex editor of choice and get to work. The range is 39 - 97. Time to pick a number to propagate. This can be any number from 0 - 255 that you choose. You can even use Mean or Median as a guide. I decided to go with 48.

You are going to have to convert the range to hex values. My range in hex is #27 - #61. Finding the hex range should be easy since the AMP file is "blank". Go look again at the screen capture above and you should be able to see what I mean. Target value also has to be converted. My target value of 48 is #30. So I went to the hex range and typed in #30 all the way down the line.

Save the AMP file and back to PS.

 

-I added a Curves Adjustment Layer and loaded the modified AMP file into it. I did that so I can paint out areas that I don't want to be affected by the Curve.

But wait, there's trouble. Damn it! It's not pixel perfect! It's not perfectly flat and I lost some of the subtleties of the text.

Well, shit happens. But it's nothing that can't be fixed or survived. Hell, if this were done on a colour image in a single channel (like Kai's example), then it might definitely be survivable. Better hidden or something.

Okay, so I screwed up the example a little bit. I can just hear somebody asking, "What's the point of being pixel perfect if you are not being pixel perfect?"

Well, this isn't about being pixel perfect for Moiré removal. Moiré removal just happens to be the example. This is about modifying an AMP file to suit our needs. Chances are you won't go through this whole ordeal just for Moiré removal. At the very least, you are now aware of AMP files, and maybe, just maybe, you'll find a use for it down the road.

-I, for one, definitely have a use for modifying an AMP file. To the left are two of my favorite Curves. I love them to death and I have *tons* of uses for them. For a taste, read Curve It.

I wrote my own Mickey Mouse program that can spit out custom AMP files with trigonomic curves. Very nice. One of these days I'm gonna write a more robust version.

Now I'm going to do a first for Technical Slop. I'm providing a download. Isn't that nice of me?

amp.zip - This file contains natural4.jpg and greyscale.amp. Load the JPG into PS and use the AMP file to curve it. Check it out. Maybe even load the AMP file into the hex editor of your choice and poke around with it.