convert image wave by a lookup wave

This procedure converts a 2D image wave with use of a lookup wave. The converted wave looks in an image plot like its unconverted counterpart that is drawn with a lookup wave.

IMPORTANT:
The function alters the image wave. So make sure to you work with duplicates.

function convertByLookUpWave(wave2d,lookupWave[,reverseColors])
	wave wave2d			// the wave to be transformed
	wave lookupWave		// the lookup wave that is used
	variable reverseColors	// pass reverseColors=1 if the original image is shown with a reversed color table

	if(wavedims(wave2d)!=2)
		print "Works only with 2-dimensional waves!"
		return 0
	endif
	if(wavemin(lookupWave) < 0 || wavemax(lookupWave)>1)
		print "Values of lookup wave must be in the range [0,1]!"
		return 0
	endif
	duplicate/free lookupWave lw,dw
	setscale/i x,0,1,dw
	wavestats/q wave2d
	if(reverseColors==1)
		setscale/i x,V_max,V_min,lw
		dw=V_max+x*(V_min-V_max)
	else
		setscale/i x,V_min,V_max,lw
		dw=V_min+x*(V_max-V_min)
	endif
	wave2d = dw(lw(wave2d[p][q]))
end

Forum

Support

Gallery

Igor Pro 10

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More