Jump to content
gautiercap

Finding and highlighting PTM coefficients

Recommended Posts

Hello,

 

I read with attention Mr. Malzbender's document about PTM Format as well as some other posts here but I haven't found a solution to my problem.

 

I would like -using the .ptm text file- to find the coefficients used to recreate the dynamic visualization. Basically a0, a1, a2, a3, a4 and a5 in the equation that gives the luminance for each pixel (C = a0Lu² + a1Lv² + a2LuLv + a3Lu + a4Lv + a5). 

 

I'm studying RGB and LRGB formats. The paper gives for both of these formats the following explanations:

 

 

PTM_FORMAT_RGB - In this case, an array of coefficients are

stored separately for each color channel. These are provided in the

following order for a single texel channel:

a0, a1, a2, a3, a4, a5

All red coefficients are stored in a block, followed by the green

channel coefficients, followed by the blue channel.

Coefficients are provided for all textels in this manner in simple

reversed scanline order (meaning from bottom to top). Note that no

separators such as <cr> are used between the individual

coefficients nor between the pixels or blocks.

 

 

 

PTM_FORMAT_LRGB - Here we store only six polynomial

coefficients representing Luminance (normalized usually) followed

by three values for R,G,B which then make up LRGB for color

calculation. The coefficients are stored per texel in a block as:

a0

I, a1

I, a2

I, a3

I, a4

I, a5

I

Followed by the RGB color values in a block ordered as:

R , G, B

Again, coefficients are provided for all textels in this manner in

simple reversed scanline order (meaning from bottom to top). Note

that no separators such as <cr> are used between the individual

coefficients nor between the pixels.

 

 

When I open any .ptm text file, I can easily find the header (type, image size,  scale and bias) but then it's a random succession of characters. Are the coefficients accessible by any means?

 

Would it also be possible to visualize them in 6 separate pictures? To see which ones have influence on some aspects of the surface (defects, indications, etc)?

 

Thanks a lot in advance,

 

Gautier

Share this post


Link to post
Share on other sites

Gautier,

 

The PTM coefficients you are trying to read out are single 8 bit characters of unsigned char. When you look at them with a Text editor like Notepad, they get interpreted as text characters, so will all look like gibberish. In a C program (or other language), read them in as unsigned chars instead, and they will span 0-255. There is an implicit offset of 127, so that values below this are negative and values above are positive. So the most negative coefficient will be 0, and the most positive one 255. The scale and bias values map these values in the range of (-1,1) to their actual floating point representation as coefficients.

 

Yes, if you read off each plane of coefficients seperately you can make 6 planes of images corresponding to the coefficients. 

 

Hope this helps,

 

Tom Malzbender

Share this post


Link to post
Share on other sites

Tom,

 

Thank you for your answer! I managed to actually find a software that converts any .ptm file into three pictures highlighting coefficients. By splitting the color channels I can compare the 6 pictures and see which coefficients change when there are cracks, holes, etc...

 

That said, I'd still like to see these coefficient values in the text file but I have zero knowledge in programming. Do I need to use a specific software to convert the text characters in numerical values? I can't find how to do so.

 

Thank you for your time and expertise,

 

Gautier

Share this post


Link to post
Share on other sites

Gautier, offhand I don't know of any way of doing this without a little bit of programming, sorry. I'd be curious what software you used to convert the ptm file to coefficient images, am not aware of that.

 

T

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×