Thursday, April 19, 2018

Grayscale height map to color gradient conversion.

A height map image, sometimes called a Digital Elevation Model DEM or Depth map, is a 2D grayscale image where brightness indicates a 3rd dimension. 

Labview's image display has a built in Gradient pallet to help enhance the contrast of the gray pixels.

It is nice to look at, but you can't save the image with the color pallet.

To create the color pallet, a new color image must be made.  The original grayscale values are used to control the Hue, Saturation and Lightness.

  • The original grayscale is squared and used as Hue.  
  • Original grayscale to the power of 4 is used as Saturation.  
  • And the original grayscale multiplied by 4 is used as Lightness.

The result is very close to the built in gradient pallet

Now there is a full RGB color image that can be saved, or sent over the network.


Monday, April 16, 2018

IR light can erase colors

Infrared light or IR, can have a surprising effect when illuminating colorful objects. It can erase the color.
Colorful candy under white light and a color camera.
Same colorful candy under IR light.


The pigments in these inks are made to absorb a specific color.  The result is a subtractive color mixing.  The objects color is defined by the color of light it does not absorb. 
In subtractive color space:
CMYK,
Cyan removes RED.
Magenta removes GREEN.
Yellow removed BLUE.
Cyan AND Magenta remove RED AND GREEN, leaving only BLUE.
Magenta AND Yellow remove GREEN AND BLUE leaving only RED.
Yellow AND Cyan remove BLUE AND RED leaving GREEN.
Cyan AND Magenta AND Yellow remove RED AND GREEN AND BLUE, leaving...BLACK.

Most color pigments have no effect on IR.  That means IR light reflects evenly, erasing difference between colors.


To get the full effect a monochrome camera should be used.  Color cameras have an IR filter.


Typical sensitivity of a Sony monochrome image sensor.


Here's another example, plastic cap colors.
White light, color camera. (Good for measuring colors)


Notice how all the color caps look the same under IR, but the brown, black and gray caps look darker.
Infrared light, Monochrome camera. (Good for ignoring color changes.)


When a white light is used with a monochrome camera, such as the image below, the color of the object will change its brightness.
White Light, Monochrome camera. (NG not good)

The take away from this is:
If color will change, and you DON'T want it to effect the results, use a monochrome camera and infrared light. 

If you want to measure the color use a color camera and white light.

Saturday, April 14, 2018

DOAL and Darkfield Lighting

Diffused On Axis Lighting or DOAL is a great way to outline surface elevation changes by making them darker.  The opposite, highlighting the elevation changes, can be done with Darkfield lighting.

DOAL effect
A coin under Diffuse On Axis Lighting, or DOAL.

Darkfield effect
Same coin inside a Darkfield light. 
What's the lighting geometry?
A DOAL light uses a beam splitter to evenly light a surface while allowing the camera to "see through" the light.  It's as if the light is coming from the camera, but in fact the beam splitter (partially silvered mirror) sends some light to the surface, and allows the light reflected off the surface to go to the camera  The beam splitter is placed between the camera and the inspection surface, at a 45 degree angle.  A diffuse light panel is placed next to the beam splitter at 90 degrees from the camera.
CCS LVF3 DOAL light.

The surface that is perpendicular to the camera will reflect the most light.  Any change in height will scatter the light.  The elevation changes will be darker as they scatter the light.

The Darkfield ring light will not reflect light from the surface perpendicular to the camera to the camera.  Only a change in elevation will reflect light to the camera.

CCS LDR-LA1 Darkfield ring light.

If Both lights are used at the same time the edges won't have the high contrast, but the entire surface can be seen. Notice how the rim of the coin can be seen in this image.

Both DOAL and Darkfield are used in this image.  The darkfield intensity is low so the edges won't be washed out.
Thanks for reading.

Tuesday, April 3, 2018

Star Target for the back of my card


Putting together a resolution checker, distortion calculator, and gamma correction target for the back of my card. 

One constant discussion is just how big a defect really is.  So I added a common defect size chart to the graphic.  

Printed at 1200 dpi, the graphic will be 3.5 x 2.0 inches.  That is the exact size of a card.  The problem is getting it printed.  The online services don't have any registration marks to lock a graphic to.  I will probably have to add a 50 pixel margin, and live with the scale error.  At least the graphics will be on the card.