石鑫华视觉论坛微信公众号:石鑫华视觉

 找回密码
 注册会员
查看: 16935|回复: 29

[原创] 3.1.16 IMAQ Cast Image转换图像

[复制链接]
  • TA的每日心情
    擦汗
    22 小时前
  • 签到天数: 3155 天

    连续签到: 25 天

    [LV.Master]2000FPS

    发表于 2016-11-17 17:03:42 | 显示全部楼层 |阅读模式 来自:广东省东莞市 电信

    注册登陆后可查看附件和大图,以及购买相关内容

    您需要 登录 才可以下载或查看,没有账号?注册会员

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

    3.1.16 IMAQ Cast Image转换图像
    转换图像,在实际使用时,还是有一定的使用价值的,可以将某种图像转换成其它指定类型的图像。例如将彩色图像转换成灰度图像,或将U8转换成U16图像。

    IMAQ Cast Image转换图像函数在程序选板中的位置

    IMAQ Cast Image转换图像函数在程序选板中的位置
    IMAQCast Image转换图像函数在程序选板中的位置

    IMAQ Cast Image转换图像函数功能说明与接线端

    IMAQ Cast 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
      
    结果

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL
    If you provide a lookup table, the  destination pixel will have the lookup value of the source pixel. If you do  not provide a lookup table, the VI copies the source value to the destination  unmodified.
      
    如果提供了一个查找表,目标像素将赋值源像素的查找值。如果不提供查找表,该函数将源像素值不修改复制到目标像素。

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL

    RGBU32

    RGBU32
    Each color component of the destination is  set to the source value. If the source value is greater than 255, the VI sets  each color component to 255. If the source value is less than 0, the VI sets  each color component to 0. If the source image has a specified bit depth, the  VI uses the bit depth when performing this conversion.
      
    目标的每个颜色分量设置为源值。如果源值大于255,则该函数将每个颜色分量设置为255。如果源值小于0,则将每个颜色分量设置为0。如果源图像具有指定的位深度,该函数使用指定位深度在执行此转换时。

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL

    HSLU32

    HSLU32
    The VI  sets the luminance component of the destination to the source value. If the  source value is greater than 255, the VI sets the luminance to 255. If the  source value is less than 0, the VI sets the luminance to 0. The VI sets hue  and saturation component of the destination to 0. If the source image has a  specified bit depth, the VI uses the bit depth when performing this  conversion.
      
    函数将目标的亮度分量设置为源值。如果源值大于255,则函数将亮度设置为255。如果源值小于0,则函数将亮度设置为0。函数将目标的色调和饱和度分量设置为0。如果源图像具有指定的位深度,该函数使用指定位深度在执行此转换时。

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL

    CSG

    CSG
    The VI sets the real component of the  destination to the source value. The VI sets the imaginary component of the  destination to 0.
      
    函数设置目标的实部分量为源值。函数设置目标的虚部为0

    U16

    U16

    I16

    I16

    U8

    U8
    The VI shifts the source value to the  right 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 than  255, 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位即为除以2N次方,N为移动位数),并将其存储该移位后的值在目标里。如果右移后的值大于255,则函数将目标值设置为255。如果移位值为零(N0),则函数使用源图像的指定位深度。
    image3.gif

    U16

    U16

    I16

    I16

    SGL

    SGL

    RGBU64

    RGBU64
    Each color component of the  destination is set to the source value. If the source value is greater than  65535, the VI sets each color component to 65535. If the source value is less  than 0, the VI sets each color component to 0.
      
    目标的每个颜色分量设置为源值。如果源值大于65535,则该函数将每个颜色分量设置为65535。如果源值小于0,则将每个颜色分量设置为0

    RGBU64

    RGBU64

    U8

    U8
    The VI shifts the source value to the 8-bit range using the specified  bit depth of the source image. Then the VI sets the destination value to  the average of the three color components of the source.
      
    该函数使用指定位深度源图像将其源值转换为8位范围(应该是每个颜色分量都使用右移,NI没有介绍)。然后将目标值设置为转换后源值的三个颜色分量的平均值。

    RGBU64

    RGBU64

    U16

    U16

    I16

    I16

    SGL

    SGL
    The VI sets the destination  value to the average of the three color components of the source. If the  average of the source color components is out of the range of the  destination, the VI coerces the average to the range.
      
    函数将目标值设置为源值的三个颜色分量的平均值的。如果源值的颜色分量平均值超出目标范围,函数强制转换平均值到范围内。

    RGBU64

    RGBU64

    RGBU32

    RGBU32
    The VI  shifts the source value to the 8-bit range using the specified bit depth of  the source image. Then the VI sets each color component in the destination  value to the corresponding component in the source value.
      
    函数使用指定位深度的源图像将其源值转换为8位范围。然后,将目标值中的每个颜色分量设置为源值中的相应分量。

    RGBU64

    RGBU64

    HSLU32

    HSLU32
    The VI shifts  the source value to the 8-bit range using the specified bit depth of the  source image. Then the VI converts each pixel from the RGB color space to the  HSL color space.
      
    函数使用指定位深度的源图像将其源值转换为8位范围。然后函数转换每个像素的RGB颜色空间到HSL颜色空间。

    U16

    U16

    I16

    I16

    SGL

    SGL
    If you provide a lookup table, the  destination pixel will have the lookup value of the source pixel. If you do  not provide a lookup table, the VI copies the source value to the destination  unmodified.
      
    如果提供了一个查找表,目标像素将由源像素的查找值赋值。如果不提供查找表,该函数将未修改的源值复制到目标中。

    SGL

    SGL

    U8

    U8

    U16

    U16

    I16

    I16
    The VI  sets the destination value to the source value. If the source value is out of  the range of the destination, the VI coerces the source to the range.
      
    函数将目标值设置为源值。如果源值超出目标的范围,函数强制转换到范围内。

    RGBU32

    RGBU32

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL
    The VI sets the destination value to the average of the three color components  of the source.
      
    函数将目标值设置为源值三个颜色分量的平均值。

    RGBU32

    RGBU32

    HSLU32

    HSLU32
    The VI converts each pixel from the RGB  color space to the HSL color space.
      
    函数转换每个像素的RGB颜色空间到HSL颜色空间。

    RGBU32

    RGBU32

    RGBU64

    RGBU64

    CSG

    CSG
    The VI  sets the real portion of the destination value to the average of the three  color components of the source, and it sets the imaginary portion of the  destination to 0.
      
    函数将目标值的实部设置为源值三个颜色分量的平均值,并将目标值的虚部设置为0

    HSLU32

    HSLU32

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL
    The VI sets the destination  value to the luminance component of the source value.
      
    函数设置目标值为源值的亮度分量。

    HSLU332

    HSLU332

    RGBU32

    RGBU32

    RGBU64

    RGBU64
    The VI converts each pixel from the HSL  color space to the RGB color space.
      
    函数转换每个像素的HSL颜色空间为RGB颜色空间。

    HSLU32

    HSLU32

    CSG

    CSG
    The VI sets the real portion of the  destination value to the value of the luminance component of the source, and  it sets the imaginary portion of the destination to 0. If the source value is  out of the range of the destination, the VI coerces the source to the range.
      
    函数将目标值的实部设置为源值亮度分量的值,将目标的虚部设置为0。如果源值超出目标的范围,范围强制转换到范围内。

    CSG

    CSG

    U8

    U8

    U16

    U16

    I16

    I16

    SGL

    SGL
    The VI  sets the destination value to the magnitude  of the source value. If the source value is out of the range of the  destination, the VI coerces the source to the range.
      
    函数将目标值设置为源值的模(复数的向量长度、大小或绝对值)。如果源值超出目标的范围,函数强制转换到范围内。

    CSG

    CSG

    RGBU32

    RGBU32

    RGBU64

    RGBU64
    The VI sets each color component of the  destination value to the magnitude of the source value. If the source value  is out of the range of the destination, the VI coerces the source to the  range.
      
    函数设置目标的每个颜色分量为源值的模。如果源值超出目标的范围,函数强制转换到范围内。

    CSG

    CSG

    HSLU32

    HSLU32
    The VI sets the luminance component of the  destination value to the magnitude of the source value, and it sets the hue  and saturation components to 0.
      
    函数设置目标的亮度分量为源值的模,并且设置色调和饱和度分量为0

    CSG

    CSG

    I16

    I16
    The VI sets the destination value to the  source value. If the source value is out of the range of the destination, the  VI coerces the source to the range.
      
    函数设置目标值为源值。如果源值超出目标值范围,函数强制转换源值到范围内。

    CSG

    CSG

    U16

    U16
    The VI sets the destination value to the  source value. If the source value is out of the range of the destination, the  VI coerces the source to the range.
      
    函数设置目标值为源值。如果源值超出目标值范围,函数强制转换源值到范围内。
    下面看一下具体的实例效果:
    游客,如果您要查看本帖隐藏内容请回复
    Cast Image转换图像程序框图

    Cast Image转换图像实例效果-将RGB32彩色图像转换为U8灰度图像

    Cast Image转换图像实例效果-将RGB32彩色图像转换为U8灰度图像
    Cast Image转换图像实例效果-RGB32彩色图像转换为U8灰度图像

    Cast Image转换图像实例效果-将RGB32彩色图像转换为HSL32图像

    Cast Image转换图像实例效果-将RGB32彩色图像转换为HSL32图像
    Cast Image转换图像实例效果-RGB32彩色图像转换为HSL32图像
    转换函数比较少用到实际项目中,如果是需要将彩色图像转换为灰度图像,一般使用抽取颜色平面即可,而且还可选择抽取哪个平面特征能最佳。所以,其实际作用并不是很明显。当然,如果是使用16位的图像,那么在某些时候可能必须要转换成8位的图像才可以处理,这里就有应用的价值了。
    另外就是,有些图像,抽取其HSL空间是会有优势一点,这样就要将图像显示为HSL。而一般的相机输出的都是RGB图像,这时就需要使用该函数,将RGB空间转换成HSL空间。
    游客,如果您要查看本帖隐藏内容请回复

    回复

    使用道具 举报

  • TA的每日心情
    郁闷
    2018-4-22 11:18
  • 签到天数: 92 天

    连续签到: 1 天

    [LV.6]600FPS

    发表于 2017-10-5 09:34:33 | 显示全部楼层 来自:湖北省荆州市 电信
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2021-11-25 09:42
  • 签到天数: 10 天

    连续签到: 1 天

    [LV.3]300FPS

    发表于 2017-7-6 15:50:28 | 显示全部楼层 来自:上海市 电信
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2021-11-25 09:42
  • 签到天数: 10 天

    连续签到: 1 天

    [LV.3]300FPS

    发表于 2017-7-6 15:50:16 | 显示全部楼层 来自:上海市 电信
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2024-2-27 08:03
  • 签到天数: 148 天

    连续签到: 1 天

    [LV.7]700FPS

    发表于 2016-12-8 15:20:46 | 显示全部楼层 来自:浙江省温州市 电信
    华视自动化http://shixinhua.com,工业相机、工业镜头、机器视觉光源、光源控制器、图像处理、系统集成服务商
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    慵懒
    2017-7-1 08:11
  • 签到天数: 3 天

    连续签到: 1 天

    [LV.2]200FPS

    发表于 2017-6-30 20:24:48 | 显示全部楼层 来自:江苏省苏州市 电信
    机器视觉商城供应各种图像采集卡,1394卡、千兆网卡、IO卡。进视觉商城https://shop128020756.taobao.com选购吧
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    擦汗
    2017-7-3 00:07
  • 签到天数: 3 天

    连续签到: 1 天

    [LV.2]200FPS

    发表于 2017-7-2 13:03:40 | 显示全部楼层 来自:北京市 联通
    回复 支持 反对

    使用道具 举报

  • TA的每日心情

    2023-11-27 15:42
  • 签到天数: 138 天

    连续签到: 1 天

    [LV.7]700FPS

    发表于 2017-7-9 16:42:26 | 显示全部楼层 来自:江苏省苏州市 联通
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    擦汗
    2017-7-10 00:29
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]100FPS

    发表于 2017-7-10 00:30:13 | 显示全部楼层 来自:陕西省西安市 电信
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2019-1-6 01:29
  • 签到天数: 8 天

    连续签到: 1 天

    [LV.3]300FPS

    发表于 2017-9-29 14:21:28 | 显示全部楼层 来自:河北省廊坊市 电信
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 注册会员

    本版积分规则

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

    QQ|石鑫华视觉论坛 |网站地图

    GMT+8, 2024-3-28 22:15

    Powered by Discuz! X3.4

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表