石鑫华视觉 发表于 2016-11-17 17:03:42

3.1.16 IMAQ Cast Image转换图像

本帖最后由 石鑫华视觉 于 2016-11-17 18:19 编辑

3.1.16 IMAQ Cast Image转换图像转换图像,在实际使用时,还是有一定的使用价值的,可以将某种图像转换成其它指定类型的图像。例如将彩色图像转换成灰度图像,或将U8转换成U16图像。IMAQCast Image转换图像函数在程序选板中的位置IMAQCast Image转换图像函数功能说明与接线端转换当前的图像类型为指定(由Image Type指定)的图像类型。如果指定了查找表,由转换图像函数使用查找表转换图像。如果转换一个16位图像到8位图像,该函数执行转换的方法为:将16位的像素值右移指定数量的移位操作(16位到8位需要右移8位),然后截取剩下的8位值。有关于转换图像的概念,可参考NI视觉概念帮助手册《NI Vision Concepts Help》。参考下面的Casting Images转换图像表来学习该函数是如何转换像素值的,当原始图像ImageSrc的类型和图像类型Image Type参数不相同时。Casting Images转换图像表
Image Src Type原始图像类型Image Type图像类型Result结果
If you provide a lookup table, thedestination pixel will have the lookup value of the source pixel. If you donot provide a lookup table, the VI copies the source value to the destinationunmodified.如果提供了一个查找表,目标像素将赋值源像素的查找值。如果不提供查找表,该函数将源像素值不修改复制到目标像素。
   Each color component of the destination isset to the source value. If the source value is greater than 255, the VI setseach color component to 255. If the source value is less than 0, the VI setseach color component to 0. If the source image has a specified bit depth, theVI uses the bit depth when performing this conversion.目标的每个颜色分量设置为源值。如果源值大于255,则该函数将每个颜色分量设置为255。如果源值小于0,则将每个颜色分量设置为0。如果源图像具有指定的位深度,该函数使用指定位深度在执行此转换时。
   The VIsets the luminance component of the destination to the source value. If thesource value is greater than 255, the VI sets the luminance to 255. If thesource value is less than 0, the VI sets the luminance to 0. The VI sets hueand saturation component of the destination to 0. If the source image has aspecified bit depth, the VI uses the bit depth when performing thisconversion.函数将目标的亮度分量设置为源值。如果源值大于255,则函数将亮度设置为255。如果源值小于0,则函数将亮度设置为0。函数将目标的色调和饱和度分量设置为0。如果源图像具有指定的位深度,该函数使用指定位深度在执行此转换时。
   The VI sets the real component of thedestination to the source value. The VI sets the imaginary component of thedestination to 0.函数设置目标的实部分量为源值。函数设置目标的虚部为0。
The VI shifts the source value to theright by the given shift value (divides each source pixel value by 2^shift )and stores the value in the destination. If the shifted value is greater than255, the VI sets the destination value to 255. If the shift value is zero,the VI uses the specified bit depth of the source image.函数将源值右移指定的位数N(右移N位即为除以2的N次方,N为移动位数),并将其存储该移位后的值在目标里。如果右移后的值大于255,则函数将目标值设置为255。如果移位值为零(N为0),则函数使用源图像的指定位深度。
   Each color component of thedestination is set to the source value. If the source value is greater than65535, the VI sets each color component to 65535. If the source value is lessthan 0, the VI sets each color component to 0.目标的每个颜色分量设置为源值。如果源值大于65535,则该函数将每个颜色分量设置为65535。如果源值小于0,则将每个颜色分量设置为0。
The VI shifts the source value to the 8-bit range using the specifiedbit depth of the source image. Then the VI sets the destination value tothe average of the three color components of the source.该函数使用指定位深度源图像将其源值转换为8位范围(应该是每个颜色分量都使用右移,NI没有介绍)。然后将目标值设置为转换后源值的三个颜色分量的平均值。
The VI sets the destinationvalue to the average of the three color components of the source. If theaverage of the source color components is out of the range of thedestination, the VI coerces the average to the range.函数将目标值设置为源值的三个颜色分量的平均值的。如果源值的颜色分量平均值超出目标范围,函数强制转换平均值到范围内。
The VIshifts the source value to the 8-bit range using the specified bit depth ofthe source image. Then the VI sets each color component in the destinationvalue to the corresponding component in the source value.函数使用指定位深度的源图像将其源值转换为8位范围。然后,将目标值中的每个颜色分量设置为源值中的相应分量。
The VI shiftsthe source value to the 8-bit range using the specified bit depth of thesource image. Then the VI converts each pixel from the RGB color space to theHSL color space.函数使用指定位深度的源图像将其源值转换为8位范围。然后函数转换每个像素的RGB颜色空间到HSL颜色空间。
If you provide a lookup table, thedestination pixel will have the lookup value of the source pixel. If you donot provide a lookup table, the VI copies the source value to the destinationunmodified.如果提供了一个查找表,目标像素将由源像素的查找值赋值。如果不提供查找表,该函数将未修改的源值复制到目标中。
The VIsets the destination value to the source value. If the source value is out ofthe range of the destination, the VI coerces the source to the range.函数将目标值设置为源值。如果源值超出目标的范围,函数强制转换到范围内。
   The VI sets the destination value to the average of the three color componentsof the source.函数将目标值设置为源值三个颜色分量的平均值。
The VI converts each pixel from the RGBcolor space to the HSL color space.函数转换每个像素的RGB颜色空间到HSL颜色空间。
The VIsets the real portion of the destination value to the average of the threecolor components of the source, and it sets the imaginary portion of thedestination to 0.函数将目标值的实部设置为源值三个颜色分量的平均值,并将目标值的虚部设置为0。
   The VI sets the destinationvalue to the luminance component of the source value.函数设置目标值为源值的亮度分量。
The VI converts each pixel from the HSLcolor space to the RGB color space.函数转换每个像素的HSL颜色空间为RGB颜色空间。
The VI sets the real portion of thedestination value to the value of the luminance component of the source, andit sets the imaginary portion of the destination to 0. If the source value isout of the range of the destination, the VI coerces the source to the range.函数将目标值的实部设置为源值亮度分量的值,将目标的虚部设置为0。如果源值超出目标的范围,范围强制转换到范围内。
   The VIsets the destination value to the magnitudeof the source value. If the source value is out of the range of thedestination, the VI coerces the source to the range.函数将目标值设置为源值的模(复数的向量长度、大小或绝对值)。如果源值超出目标的范围,函数强制转换到范围内。
The VI sets each color component of thedestination value to the magnitude of the source value. If the source valueis out of the range of the destination, the VI coerces the source to therange.函数设置目标的每个颜色分量为源值的模。如果源值超出目标的范围,函数强制转换到范围内。
The VI sets the luminance component of thedestination value to the magnitude of the source value, and it sets the hueand saturation components to 0.函数设置目标的亮度分量为源值的模,并且设置色调和饱和度分量为0。
The VI sets the destination value to thesource value. If the source value is out of the range of the destination, theVI coerces the source to the range.函数设置目标值为源值。如果源值超出目标值范围,函数强制转换源值到范围内。
The VI sets the destination value to thesource value. If the source value is out of the range of the destination, theVI coerces the source to the range.函数设置目标值为源值。如果源值超出目标值范围,函数强制转换源值到范围内。
下面看一下具体的实例效果:**** Hidden Message *****Cast Image转换图像程序框图Cast Image转换图像实例效果-将RGB32彩色图像转换为U8灰度图像Cast Image转换图像实例效果-将RGB32彩色图像转换为HSL32图像转换函数比较少用到实际项目中,如果是需要将彩色图像转换为灰度图像,一般使用抽取颜色平面即可,而且还可选择抽取哪个平面特征能最佳。所以,其实际作用并不是很明显。当然,如果是使用16位的图像,那么在某些时候可能必须要转换成8位的图像才可以处理,这里就有应用的价值了。另外就是,有些图像,抽取其HSL空间是会有优势一点,这样就要将图像显示为HSL。而一般的相机输出的都是RGB图像,这时就需要使用该函数,将RGB空间转换成HSL空间。**** Hidden Message *****

ak47m16u571 发表于 2017-10-5 09:34:33

nice                              

caifeng0404 发表于 2017-7-6 15:50:28

学习一下                感谢站长      

caifeng0404 发表于 2017-7-6 15:50:16

学习一下                        

wangqiuxiang 发表于 2016-12-8 15:20:46

华视自动化http://shixinhua.com,工业相机、工业镜头、机器视觉光源、光源控制器、图像处理、系统集成服务商

287479272 发表于 2017-6-30 20:24:48

机器视觉商城供应各种图像采集卡,1394卡、千兆网卡、IO卡。进视觉商城https://shop128020756.taobao.com选购吧

Trevorsong 发表于 2017-7-2 13:03:40

点点滴滴柔柔弱弱若

1104755958 发表于 2017-7-9 16:42:26

很不错的资料,非常感谢,忠实的粉丝………………

蓝色希望 发表于 2017-7-10 00:30:13

学习,O(∩_∩)O谢谢

lver 发表于 2017-9-29 14:21:28

真是确实帮助我解决问题!
页: [1] 2 3 4
查看完整版本: 3.1.16 IMAQ Cast Image转换图像

LabVIEW HALCON图像处理入门教程(第二版)
石鑫华机器视觉与LabVIEW Vision图像处理PDF+视频教程11种全套
《LabVIEW Vision函数实例详解》教程-NI Vision所有函数使用方法介绍,基于NI VISION2020,兼容VDM21/22/23