Home > Software engineering >  Decoding Keyence LJ-X8000 Bitmap-Height Image
Decoding Keyence LJ-X8000 Bitmap-Height Image

Time:07-01

I have a Keyence Line Laser System LJ-X 8000, that I use to scan the surface of different objects.
The Controller saves the height information as a bitmap, with each pixel representing one height value. After a lot of tinkering, I found out, that Keyence is not using the actual colors, rather than using the 24-Bit RGB-triplets as some form of binary storage. However, no combination of these bytes seems to work for me. Are there any common storage methods for 24-bit Integers?

CodePudding user response:

To decode those values, I did a scan covering the whole measurement range of the scanner, including some out of range values in the beginning and the end. If I look at the distribution of the values of each color plane, you can see, that the first and third plane actually only use 8/16 Bits. This is also visible in the image itself, as it mainly shows green.

I concluded that Keyence uses the full byte of the green color plane, 3 Bits of the first and 4 Bits of the last plane to store the height information. Keyence seems to have chosen some weird 15 Bit Integer Format to store their data.

With a little bit-shifting and knowing that the scanner has a valid range from [-2.2, 2.2] I was able to build the following simple little (Matlab-) script to calculate the height information for each pixel:

HeightValBin = bitshift(scanIm(:,:,2),7, 'uint16') ...
                 bitshift(scanIm(:,:,1),4, 'uint16')...
                 bitshift(scanIm(:,:,3),0, 'uint16');
scanBinValScaled = interp1([0,2^15], [-2.2, 2.2], double(scanBinVal));

Keyence offers a software to convert those .bmp into .csv-files, but without an API to automate the process. As I will have to deal with a lot of these files I needed to automate this process.

The calculated values from the rgb triplets are actually even more precise than the exported csv, as the csv only shows 4 digits after the decimal point.

Binary Values of the color planes

enter image description here

  • Related