halcon 函数gamma_image 函数说明
- 格式:doc
- 大小:14.36 KB
- 文档页数:4
Halcon学习(二十二)摄像机标定(函数详解)TmpCtrl_AllMarkRows := []TmpCtrl_AllMarkColumns := []TmpCtrl_StartPoses := []TmpCtrl_ReferenceIndex := 0StartParameters := [0.008,0,5.2e-006,5.2e-006,640,512,1280,1024]for Index := 0 to |ImageFiles|-1 by 1read_image (Image, ImageFiles[Index])find_caltab (Image, TmpObj_PlateRegion, 'E:/calibration_description/caltab_123mm.descr', 3, 112, 5) find_marks_and_pose (Image, TmpObj_PlateRegion, 'E:/calibration_description/caltab_123mm.descr', StartParameters, 128, 10, 18, 0.9, 15, 100, TmpCtrl_MarkRows, TmpCtrl_MarkColumns, TmpCtrl_EstimatedPose)TmpCtrl_AllMarkRows := [TmpCtrl_AllMarkRows, TmpCtrl_MarkRows]TmpCtrl_AllMarkColumns := [TmpCtrl_AllMarkColumns, TmpCtrl_MarkColumns]TmpCtrl_StartPoses := [TmpCtrl_StartPoses, TmpCtrl_EstimatedPose]endforcaltab_points('E:/calibration_description/caltab_123mm.descr', TmpCtrl_X, TmpCtrl_Y, TmpCtrl_Z)camera_calibration (TmpCtrl_X, TmpCtrl_Y, TmpCtrl_Z, TmpCtrl_AllMarkRows, TmpCtrl_AllMarkColumns, StartParameters, TmpCtrl_StartPoses, 'all', CameraParameters, TmpCtrl_FinalPoses, TmpCtrl_Errors)tuple_select_range (TmpCtrl_FinalPoses, 7*TmpCtrl_ReferenceIndex, 7*TmpCtrl_ReferenceIndex + 6, CameraPose)set_origin_pose (CameraPose, 0.0, 0.0, 0.001, CameraPose)stop ()一、读入图像,函数如下list_files ('E:/calibration_image', 'files', ImageFiles)for Index := 0 to |ImageFiles|-1 by 1read_image(Image, ImageFiles[Index])endfor注释:'E:/calibration_image':为图像路径,图像文件索引是从0开始的,所以|ImageFiles|(文件数量)减去1。
halcon map_image原理Halcon Map_Image原理Halcon是一款广泛应用于机器视觉领域的图像处理软件,其中的Map_Image函数是其重要的功能之一。
本文将围绕着Halcon Map_Image的原理进行详细介绍。
一、Map_Image函数的作用Map_Image函数在Halcon中用于将输入图像中的像素值映射到输出图像中。
通过该函数,用户可以对图像进行灰度映射、颜色映射和像素值转换等操作,以实现对图像的增强、调整和处理。
二、Map_Image函数的参数Map_Image函数的参数包括输入图像(Image),输出图像(Image), 映射类型(Type)和映射参数(Param)等。
其中,输入图像为待处理的原始图像,输出图像为处理后的结果图像。
映射类型决定了如何映射像素值,常见的类型有线性映射、非线性映射和颜色映射等。
映射参数则根据映射类型的不同提供不同的设置选项,以满足用户对图像处理的需求。
三、Map_Image的实现原理Map_Image函数的实现原理主要分为以下几个步骤:1. 参数检查:首先,Halcon会对输入的图像、映射类型和映射参数进行合法性检查,确保输入的图像和参数符合要求。
2. 图像分析:Halcon会对输入图像进行分析,获取图像的尺寸、分辨率和通道数等信息。
3. 空白图像生成:根据输入图像的信息,Halcon会生成一个与输入图像大小相同的空白图像,用于存储处理后的结果。
4. 像素值映射:根据映射类型和映射参数,Halcon会对输入图像中的每个像素值进行映射计算,并将结果存储到输出图像中的对应位置。
5. 结果显示:最后,Halcon会将输出图像显示在屏幕上,供用户查看和进一步处理。
四、Map_Image的应用场景Map_Image函数在机器视觉领域有着广泛的应用场景,如图像增强、图像调整、目标检测、图像分割等。
通过对图像的像素值进行映射,可以使图像的亮度、对比度、颜色等特征得到调整和增强,从而提高图像处理的效果和准确度。
Halcon1.图像的平滑:图像平滑的主要⽬的是减少图像的噪声。
(1)smooth_image(Image:ImageSmooth:Filter,Alpha:)功能描述:使⽤递归滤波器对图像进⾏平滑(⾼斯滤波使⽤⾮递归滤波器)参数:Image(输⼊参数):输⼊图像;ImageSmooth(输出参数):滤波后的图像;Filter(输⼊参数):滤波器;Alpha(输⼊参数):滤波参数:值越⼩,滤波效果越好(⾼斯滤波刚好相反);(2)sigma_image(Image:ImageSigma:MaskHeight,MaskWidth,Sigma:)功能描述:使⽤sigma(标准⽅差),对图像进⾏⾮线性滤波。
参数:Image(输⼊参数):输⼊图像;ImageSigma(输出参数):滤波后的图像;MaskHeight(输⼊参数):掩码的⾼度;MaskWidth(输⼊参数):掩码的宽度;Sigma(输⼊参数):平均的最⼤偏差;(3)mean_image(Image:ImageMean:MaskWidth,MaskHeight:)功能描述:对图像进⾏均值滤波。
参数:Image(输⼊参数):输⼊图像;ImageMean(输出参数):滤波后的图像;MaskWidth(输⼊参数):滤波掩码的宽度;MaskHeight(输⼊参数):滤波掩码的⾼度;(4)gauss_image(Image:ImageGauss:Size)功能描述:使⽤离散⾼斯函数对图像进⾏滤波。
参数:Image(输⼊参数):输⼊图像;ImageGauss(输出参数):滤波后的图像;Size(输⼊参数):滤波器尺⼨;2.中值滤波算⼦:median(Image:ImageMedian:MaskType,Radius,Margin:) 功能描述:使⽤多种掩膜对图像进⾏中值滤波。
参数:Image(输⼊参数):输⼊图像;ImageMedian(输出参数):滤波后的图像;MaskType(输⼊参数):滤波掩码种类('circle','square');Radius(输⼊参数):滤波掩膜半径;Margin(输⼊参数):边界处理⽅式;3.图像的锐化:图像锐化的⽬的是为了使图像的边缘、轮廓线以及图像的细节变得清晰。
Halcon算法加速的基础知识(多核并⾏GPU)⼀、提⾼Halcon的运算速度,有以下⼏种⽅法:1、Multithreading(多线程)2、Automatic Parallelization(⾃动操作并⾏化)3、Compute devices,利⽤GPU提速,如果显卡性能好,⾄少可以提⾼5~10倍的运算速度⼆、多线程1、官⽅⾃带的例程get_operator_info.hdev,可以查看⽀持多线程的算⼦;1 * Determine the multithreading information2 get_multithreading_operators (TypeExclusive, TypeMutual, TypeReentrant, TypeIndependent)3 * ⾃定义函数展开之后,有get_operator_info算⼦4 * get names of all operators of the library5 get_operator_name ('', OperatorNames)6 get_operator_info (OperatorNames[Index], 'parallelization', Information)2、官⽅的⼿册C:\Program Files\MVTec\HALCON-19.11-Progress\doc\pdf\manuals\programmers_guide.pdfChapter 2 Parallel Programming and HALCONC:\Program Files\MVTec\HALCON-19.11-Progress\doc\pdf\reference\reference_hdevelop.pdfChapter 25 System --- 25.6 Multithreading三、多核并⾏看看官⽅的说明,关于HALCON-多核性能:1、算⼦⾃动并⾏化(AOP)Automatic Operator Parallelization (AOP)多核和多处理器的计算机显著提升了计算机视觉系统的速度。
halcon 函数gamma_image 函数说明-回复Function Overview:The gamma_image function is a powerful tool in the Halcon software library. It allows users to adjust the gamma correction of an image. Gamma correction is a technique used to alter the brightness levels of an image in a non-linear fashion. This function has several parameters that can be adjusted to achieve the desired effect.Step 1: Understanding Gamma CorrectionGamma correction is used to modify the brightness levels of an image to match the characteristics of a display device. It is essential because human perception of brightness is not linear; our eyes perceive changes in brightness logarithmically. Gamma correction is applied to achieve a more visually pleasing image by compensating for the non-linear response of the display.Step 2: Analyzing the Function ParametersThe gamma_image function has several parameters that need to be understood before using it effectively. These parameters include the input image, the gamma factor, the minimum intensity, and the maximum intensity. Let's delve into each parameter in detail:- Input Image: This parameter specifies the image upon which gamma correction will be applied. It can be a grayscale or color image. The image can be stored in memory or loaded from a file.- Gamma Factor: The gamma factor is the most critical parameter in the function. It determines the amount of gamma correction applied to the image. A value less than 1 reduces the brightness, while a value greater than 1 increases it. The gamma factor directly influences the overall contrast of the image.- Minimum Intensity: This parameter sets the minimum intensity level of the output image. Any pixel with an intensity below this value will be adjusted to the minimum value. It can be useful for excluding dark areas from gamma correction.- Maximum Intensity: This parameter sets the maximum intensity level of the output image. Any pixel with an intensity above this value will be adjusted to the maximum value. It can be useful for excluding bright areas from gamma correction.Step 3: Applying Gamma CorrectionTo use the gamma_image function, follow these steps:1. Load an input image: This can be done using the appropriate Halcon function to read an image from file or capturing it from a camera.2. Set the desired gamma factor: Determine whether you want to increase or decrease the image's brightness. Experiment with different gamma values to achieve the desired effect.3. Adjust the minimum and maximum intensity values: If needed, set the range of intensity values you want to exclude from gamma correction. This helps retain the details in darker or brighter regions of the image.4. Call the gamma_image function: Pass the input image, gamma factor, minimum intensity, and maximum intensity as parameters to the function. It will perform the gamma correction and produce the output image.5. Display or save the output image: Use the appropriate Halcon function to display the adjusted image on-screen for visualinspection or save it to the disk for further analysis and processing.Step 4: Additional ConsiderationsHere are some additional points to keep in mind while using the gamma_image function:- Gamma correction can impact image details: Depending on the chosen gamma value, details in dark or bright regions of the image may be lost or enhanced. It is essential to find the right balance that preserves the crucial details.- Image quality considerations: Applying gamma correction can introduce artifacts or loss of information in the image. It is advisable to work with high-quality images and considerpost-processing techniques to alleviate these issues.- Optimization considerations: The gamma_image function can be computationally intensive for large images. Consider using optimized programming techniques or applying the function on smaller image patches to improve processing speed.In conclusion, the gamma_image function in Halcon is a versatiletool for adjusting the gamma correction of images. By understanding the function parameters and following thestep-by-step process, users can effectively apply gamma correction to enhance image brightness and contrast. It offers a wide range of possibilities for image enhancement and adaptation to different display devices with non-linear brightness characteristics.。
HALCON函数介绍HALCON函数介绍(转)sobel_amp( Image : EdgeAmplitude : FilterType, Size : )根据图像的一次导数计算图像的边缘close_edges( Edges, EdgeImage : RegionResult : MinAmplitude : )close_edges_length( Edges, Gradient : ClosedEdges : MinAmplitude, MaxGapLength : ) 使用边缘高度图像关闭边缘间隙。
输出的区域包含杯关闭的区域。
(感觉是对边缘的扩充)derivate_gauss( Image : DerivGauss : Sigma, Component : )watersheds( Image : Basins, Watersheds : : )从图像中提取风水岭。
zero_crossing( Image : RegionCrossing : : )零交点(二次导数)diff_of_gauss( Image : DiffOfGauss : Sigma, SigFactor : )近似日志算子( 拉普拉斯高斯) 。
laplace_of_gauss( Image : ImageLaplace : Sigma : )拉普拉斯高斯edges_color_sub_pix( Image : Edges : Filter, Alpha, Low, High : )精确的亚像素边缘提取(彩色图像)edges_sub_pix( Image : Edges : Filter, Alpha, Low, High : )精确边缘提取的亚像素(灰度图像)edges_color( Image : ImaAmp, ImaDir : Filter, Alpha, NMS, Low, High : )根据颜色进行边缘提取edges_image( Image : ImaAmp, ImaDir : Filter, Alpha, NMS, Low, High : )边缘提取skeleton( Region : Skeleton : : )计算区域的框架Skeleton == Regionfrei_amp( Image : ImageEdgeAmp : : )Frei-chen模板进行边缘检测(振幅)frei_dir( Image : ImageEdgeAmp, ImageEdgeDir : : ) Frei-chen 模板进行边缘检测(振幅和方向)nonmax_suppression_dir( ImgAmp, ImgDir : ImageResult : Mode : )使用方向图像抑制所有的超过给定最大值的图像灰度值的点gen_contours_skeleton_xld( Skeleton : Contours : Length, Mode : ) 将系统框架转换成XLD轮廓laplace( Image : ImageLaplace : ResultType, MaskSize, FilterMask : )使用有限差分计算拉普拉斯变换info_edges( : : Filter, Mode, Alpha : Size, Coeffs )估计滤波器的宽度kirsch_dir( Image : ImageEdgeAmp, ImageEdgeDir : : )使用Kirsch算子计算出边缘(振幅和方向)prewitt_amp( Image : ImageEdgeAmp : : )使用Prewitt 算子计算出边缘(振幅)kirsch_amp( Image : ImageEdgeAmp : : ) 使用Kirsch 算子计算出边缘(振幅)highpass_image( Image : Highpass : Width, Height : )从高频成分提取的图像。
HALCON算子函數——Chapter 5 : FilterChapter_5:Filter 5.1 Arithmetic1. abs_image功能:計算一個圖像的絕對值(模數)。
2. add_image功能:使兩個圖像相加。
3. div_image功能:使兩個圖像相除。
4. invert_image功能:使一個圖像反像。
5. max_image功能:按像素計算兩個圖像的最大值。
6. min_image功能:按像素計算兩個圖像的最大小值。
7. mult_image功能:使兩個圖像相乘。
8. scale_image功能:為一個圖像的灰度值分級。
9. sqrt_image功能:計算一個圖像的平方根。
10. sub_image功能:使兩個圖像相減。
5.2 Bit1. bit_and功能:輸入圖像的所有像素的逐位與。
2. bit_lshift功能:圖像的所有像素的左移。
3. bit_mask功能:使用位掩碼的每個像素的邏輯與。
4. bit_not功能:對像素的所有位求補。
5. bit_or功能:輸入圖像的所有像素的逐位或。
6. bit_rshift功能:圖像的所有像素的右移。
7. bit_slice功能:從像素中提取一位。
8. bit_xor功能:輸入圖像的所有像素的逐位異或。
5.3 Color1. cfa_to_rgb功能:把一個單通道顏色濾波陣列圖像變成RGB圖像。
2. gen_principal_comp_trans功能:計算多通道圖像的主要部分分析的轉換矩陣。
3. linear_trans_color功能:計算多通道圖像的顏色值的一個仿射轉換。
4. principal_comp功能:計算多通道圖像的主要部分。
5. rgb1_to_gray功能:把一個RGB圖像轉變成一個灰度圖像。
6. rgb3_to_gray功能:把一個RGB圖像轉變成一個灰度圖像。
7. trans_from_rgb功能:把一個圖像從RGB顏色空間轉變成任意顏色空間。
HALCON算子函数——Chapter 5 : Filter 5.1 Arithmetic1. abs_image功能:计算一个图像的绝对值(模数)。
2. add_image功能:使两个图像相加。
3. div_image功能:使两个图像相除。
4. invert_image功能:使一个图像反像。
5. max_image功能:按像素计算两个图像的最大值。
6. min_image功能:按像素计算两个图像的最大小值。
7. mult_image功能:使两个图像相乘。
8. scale_image功能:为一个图像的灰度值分级。
9. sqrt_image功能:计算一个图像的平方根。
10. sub_image功能:使两个图像相减。
5.2 Bit1. bit_and功能:输入图像的所有像素的逐位与。
2. bit_lshift功能:图像的所有像素的左移。
3. bit_mask功能:使用位掩码的每个像素的逻辑与。
4. bit_not功能:对像素的所有位求补。
5. bit_or功能:输入图像的所有像素的逐位或。
6. bit_rshift功能:图像的所有像素的右移。
7. bit_slice功能:从像素中提取一位。
8. bit_xor功能:输入图像的所有像素的逐位异或。
5.3 Color1. cfa_to_rgb功能:把一个单通道颜色滤波阵列图像变成RGB图像。
2. gen_principal_comp_trans功能:计算多通道图像的主要部分分析的转换矩阵。
3. linear_trans_color功能:计算多通道图像的颜色值的一个仿射转换。
4. principal_comp功能:计算多通道图像的主要部分。
5. rgb1_to_gray功能:把一个RGB图像转变成一个灰度图像。
6. rgb3_to_gray功能:把一个RGB图像转变成一个灰度图像。
7. trans_from_rgb功能:把一个图像从RGB颜色空间转变成任意颜色空间。
Halcon是一款由德国MVTec Software GmbH开发的先进机器视觉软件。
其丰富的功能和灵活的应用使得Halcon备受行业内广泛关注。
在Halcon中,mirror image(镜像)是一项常用的功能,在图像处理和分析中有着重要的作用。
mirror image的功能是将图像进行镜像处理,使得原始图像左右对称,从而实现对图像的翻转操作。
其使用方法如下:1. 载入图像:在使用mirror image功能之前,首先需要载入需要进行镜像处理的图像。
在Halcon中,可以通过常见的图像文件格式(如.bmp、.jpg等)来载入图像,也可以通过相机直接获取图像进行处理。
2. 调用mirror image函数:在载入图像后,可以使用Halcon提供的mirror_image函数来对图像进行镜像处理。
该函数接受待处理图像和处理后的镜像图像作为参数,并返回处理后的镜像图像。
3. 设置镜像类型:mirror_image函数还可以根据用户的需求设置不同的镜像类型,包括水平镜像和垂直镜像,以实现不同方向的翻转操作。
用户可以根据具体需求来选择合适的镜像类型。
4. 处理镜像:一旦设置好镜像类型,就可以调用mirror_image函数对图像进行镜像处理。
处理完成后,会得到处理后的镜像图像,可以用于后续的图像分析和处理。
除了基本的镜像处理功能外,Halcon中的mirror_image还提供了丰富的参数设置和灵活的应用方式,可以满足不同用户的需求。
使用mirror_image功能可以实现图像的快速处理和分析,为机器视觉应用提供了重要的支持。
在实际应用中,mirror_image功能可以广泛应用于工业检测、医疗影像、智能交通等领域。
在工业检测中,可以利用镜像处理技术对产品进行缺陷检测;在医疗影像中,可以对患者的影像数据进行镜像处理以辅助诊断;在智能交通中,可以利用镜像处理技术对车辆进行识别和监控。
Halcon中的mirror_image功能具有重要的应用意义,可以实现图像的快速处理和分析,并为机器视觉应用提供有效的支持。
Halcon学习(⼆⼗⼀)摄像机标定常⽤函数(⼆)1.read_cam_par( : : : )从⽂件夹中读取相机的内参数。
2.disp_caltab( : : , , , , : )利⽤相机内外参数,把标定板模型投影到图像平⾯,显⽰标定点和连接线,X,Y轴也被显⽰出来。
3.vector_to_pose( : : , , , , , ,, : , )计算世界坐标和图像坐标之间关系的绝对位姿参数。
其中世界坐标⾄少选择不在同⼀条直线上的三个点。
世界坐标上的点如果在⼀个平⾯上,应该选择'planar_analytic'作为Method的参数。
输出位姿和位姿质量。
4.write_pose( : : , : )把位姿写⼊TXT⽂件。
5.get_mbutton( : : : , , )返回⿏标点击的图像点像素坐标,以及⿏标按钮值,左键0,中间键2,右键4.6.image_points_to_world_plane( : : , , , , : ,)把图像坐标转化成Z=0平⾯的世界坐标,输出为世界坐标的X,Y7.pose_to_hom_mat3d( : : : )把3D位姿转化成齐次变换矩阵。
8.affine_trans_point_3d( : : , , , : , , )进⾏两个坐标系之间的3D坐标的仿射变换。
/ Qx \ / Px \| Qy | = HomMat3D * | Py || Qz | | Pz |\ 1 / \ 1 /9.project_3d_point( : : , , , : , )把3D点映射到图像坐标系,返回图像坐标系中该点的⾏列坐标。
10.smallest_rectangle2( : : : , , , , )返回包含⼀个区域的最⼩环绕矩形。
11.gen_measure_rectangle2( : : , , , , , , , : )返回和矩形边垂直的边缘。
12.measure_pairs( : : , , , , :, , , , ,, , )抽取和矩形边垂直的边缘对。
halcon 函数gamma_image 函数说明
关于Halcon函数gamma_image的详细说明
Halcon是一款强大的机器视觉开发软件,拥有丰富的函数库以及各种各样的图像处理函数。
gamma_image就是其中之一,它是用来调整图像的亮度和对比度的函数。
在本文中,我们将详细介绍gamma_image函数的使用方法和注意事项。
1. gamma_image函数的基本介绍
gamma_image函数通过改变输入图像的亮度和对比度来实现图像的增强。
在图像处理中,亮度指图像像素的明亮程度,而对比度指图像中亮度变化的范围。
使用gamma_image函数,我们可以通过调整亮度和对比度,使图像更加清晰、明亮,并提高其可视化效果。
2. gamma_image函数的语法和参数
gamma_image函数的语法如下:
gamma_image (Image : ImageGamma, Gamma : real)
参数说明:
- Image: 输入图像
- ImageGamma: 输出图像
- Gamma: 亮度调整参数,范围为[0,∞],默认值为1.0
3. gamma_image函数的使用方法
在使用gamma_image函数前,我们首先要加载Halcon的相关库函数,并读取待处理的图像。
下面是一个简单的代码示例:
python
# 加载相关库函数
from halcon import *
# 读取待处理图像
image = read_image("input.jpg")
在加载库函数和读取图像之后,我们可以使用gamma_image函数来增强图像。
下面是一个具体的代码示例:
python
# 调整亮度和对比度
gamma = 1.5
gamma_image(image, image_gamma, gamma)
在上述代码示例中,我们设置了亮度调整参数为1.5,并将增强后的图像存储在image_gamma变量中。
4. gamma_image函数的注意事项
在使用gamma_image函数时,我们需要注意以下几点:
4.1 亮度调整参数的选择
亮度调整参数(gamma)的选择会直接影响图像的亮度和对比度。
当gamma小于1时,图像的亮度会减小,对比度增加;当gamma大于1时,图像的亮度会增加,对比度降低。
我们可以通过调整gamma的值来获得不同的图像效果。
4.2 输入图像的格式
gamma_image函数对图像的格式要求较高,只能处理灰度图像和RGB 色彩空间图像。
如果输入图像不符合要求,需要进行必要的格式转换才能使用gamma_image函数进行处理。
4.3 输出图像的范围
gamma_image函数的输出图像像素的取值范围为[0,255]。
如果输出图像的像素超过了这个范围,需要进行归一化处理,以确保图像的正确显示。
5. 结语
gamma_image函数是Halcon中一个常用的图像处理函数,通过调整亮度和对比度,可以优化图像的可视化效果。
在使用该函数时,我们需要注意亮度调整参数的选择、输入图像的格式以及输出图像的范围。
通过合理地使用gamma_image函数,我们可以获得更好的图像处理效果。
希望本文对您理解和使用gamma_image函数有所帮助。