WO2020135056A1 - 一种图像处理方法及装置 - Google Patents

一种图像处理方法及装置 Download PDF

Info

Publication number
WO2020135056A1
WO2020135056A1 PCT/CN2019/124599 CN2019124599W WO2020135056A1 WO 2020135056 A1 WO2020135056 A1 WO 2020135056A1 CN 2019124599 W CN2019124599 W CN 2019124599W WO 2020135056 A1 WO2020135056 A1 WO 2020135056A1
Authority
WO
WIPO (PCT)
Prior art keywords
gray value
image
pixel
processed
pixel point
Prior art date
Application number
PCT/CN2019/124599
Other languages
English (en)
French (fr)
Inventor
佟卉斌
Original Assignee
北京金山安全软件有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京金山安全软件有限公司 filed Critical 北京金山安全软件有限公司
Publication of WO2020135056A1 publication Critical patent/WO2020135056A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling

Definitions

  • the present application relates to the field of image processing technology, in particular to an image processing method and device.
  • the connected domain in the image refers to the image area composed of pixels with the same gray value and adjacent positions in the image.
  • the recognition of connected domains is widely used in image processing.
  • the recognition of connected domains is applied to image processing such as license plate recognition and contour drawing in puzzle games.
  • the outline maps used in puzzle games are obtained from the actual color maps taken.
  • the game producer recognizes the connected domains in the actual captured color map by manually recognizing the image, and hand-draws the connected domain boundaries in the actually captured color map on the image composed of white pixels, and then obtains the white A contour map composed of pixels and black pixels.
  • the recognition of connected domains not only takes a long time, but also wastes human resources.
  • the purpose of the embodiments of the present application is to provide an image processing method and device to solve the problems of manually identifying connected domains in images that take a long time and waste human resources.
  • the specific technical solutions are as follows:
  • an embodiment of the present application provides an image processing method.
  • the method includes:
  • the binarized image to be processed includes: a contour image area and a non-contour image area, and the grayscale of pixel points in the contour image area The value is the first gray value, and the gray value of the pixels in the non-contour image area is the second gray value;
  • the target pixel point is determined by a flood filling algorithm
  • the determination of the target pixel point by the flood filling algorithm based on the pixel point based on the second gray value includes:
  • a target pixel point is determined by a flood filling algorithm, and the gray value of the target pixel point is set to a preset gray value.
  • the method further includes:
  • Determining the modified image as a binary image to be processed and returning to the step of selecting the pixel point of the second gray value from the binary image to be processed as a starting pixel point.
  • the target pixel is determined by a flood filling algorithm, and the gray value of the target pixel is set to a preset gray value, including:
  • the selecting the pixel point of the second gray value from the binary image to be processed as the starting pixel point includes:
  • the pixel point of the second gray value traversed for the first time is determined as the starting pixel point.
  • performing binary processing on the image to be processed to obtain the binary image to be processed includes:
  • an embodiment of the present application provides an image processing apparatus, the apparatus including:
  • the processing module is configured to perform binarization processing on the image to be processed to obtain a binarized image to be processed; wherein, the binarized image to be processed includes: a contour image area and a non-contour image area, and among the contour image areas The gray value of the pixel is the first gray value, and the gray value of the pixel in the non-contour image area is the second gray value;
  • a first determining module configured to determine the target pixel point through a flood filling algorithm based on the pixel point of the second gray value
  • the recording module is used to record the target pixel.
  • the first determining module is specifically used to:
  • a target pixel point is determined by a flood filling algorithm, and the gray value of the target pixel point is set to a preset gray value.
  • the device further includes:
  • a setting module configured to set the gray value of the pixel point of the preset gray value to the first gray value after recording the target pixel point of the preset gray value to obtain a modified image
  • a second determining module configured to determine the modified image as a to-be-processed binarized image, and triggering the first determining module to perform the selecting of the second from the to-be-processed binarized image
  • the pixel of the gray value is used as the step of the starting pixel.
  • the first determining module is specifically used to:
  • the first determining module is specifically used to:
  • the pixel point of the second gray value traversed for the first time is determined as the starting pixel point.
  • processing module is specifically used to:
  • an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
  • Memory used to store computer programs
  • the processor is configured to execute any of the image processing method steps described above when executing the program stored on the memory.
  • an embodiment of the present application provides a machine-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, any of the image processing methods described above is implemented step.
  • an embodiment of the present application provides a computer program that implements any of the steps of the image processing method described above when the computer program is executed by a processor.
  • the image to be processed is binarized to obtain the binarized image to be processed.
  • the target pixel is determined by the flood filling algorithm, and the target is recorded pixel.
  • the image to be processed is binarized to obtain the image to be processed.
  • the image to be processed is outlined by the first gray value and the second gray value.
  • the image area is distinguished from the non-contour image area.
  • all pixels in the area composed of the pixels with the second gray value can be determined by the flood filling algorithm to determine the pixels belonging to the same connected domain Target pixels are recorded, and then the connected domains in the image are recognized without manual participation, which saves human resources and solves the problem that it takes a long time and wastes human resources to manually identify the connected domains in the image.
  • FIG. 1 is a schematic flowchart of an image processing method provided by an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of an image processing apparatus provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • embodiments of the present application provide an image processing method and device, where the image processing method includes:
  • Binary processing is performed on the image to be processed to obtain a binary image to be processed; wherein the binary image to be processed includes: a contour image area and a non-contour image area, and the gray value of the pixels in the contour image area is the first Gray value, the gray value of the pixels in the non-contour image area is the second gray value;
  • the target pixels are determined by the flood filling algorithm
  • the image to be processed is binarized to obtain the binarized image to be processed.
  • the target pixel is determined by the flood filling algorithm, and the target is recorded pixel.
  • the image to be processed is binarized to obtain the image to be processed.
  • the image to be processed is outlined by the first gray value and the second gray value.
  • the image area is distinguished from the non-contour image area.
  • all pixels in the area composed of pixels with the second gray value can be determined by the flood filling algorithm, that is, those belonging to the same connected domain can be determined
  • Target pixels are recorded, and then the connected domains in the image are recognized without manual participation, which saves human resources and solves the problem that it takes a long time and wastes human resources to manually identify the connected domains in the image.
  • An image processing method provided by an embodiment of the present application includes the following steps.
  • S101 Perform binarization processing on the image to be processed to obtain a binarized image to be processed.
  • the image to be processed may be any image such as a color image or a grayscale image.
  • the color to be processed image can be converted into a single-channel grayscale image.
  • the open source computer vision library Open Source Computer Vision (Library, OpenCV)
  • the grayscale image is binarized, and then a binarized image can be obtained.
  • the obtained binarized image includes only black and white colors. For example, only pixels with a gray value of 0 and pixels with a gray value of 255 are included.
  • the obtained binarized image may be subjected to noise reduction processing to improve the quality of the binarized image.
  • the binary image to be processed includes: contour image area and non-contour image area, the gray value of pixels in the contour image area is the first gray value, and the gray value of pixels in the non-contour image area is The second gray value.
  • the contour image area is used to highlight the contours of people, objects and other objects in the binary image to be processed. It can be considered that the contour image area is composed of lines formed by adjacent pixels with the same gray value, and each line is combined to form a contour that highlights the target.
  • the non-contour image area is the area other than the contour image area in the binary image to be processed.
  • the first gray value and the second gray value may include the following two Case: In the first case, the first gray value is 0 and the second gray value is 255; in the second case, the first gray value is 255 and the second gray value is 0.
  • the non-contour image area is an area composed of white pixels
  • the contour image area is an area composed of black pixels.
  • white is used as the base color
  • black lines are used to highlight the outline of the target.
  • the non-contour image area is an area composed of black pixels
  • the contour image area is an area composed of white pixels.
  • black is used as the base color
  • white lines are used to highlight the outline of the target.
  • the first case is used as an example for description.
  • the resulting image is a binarized image, that is, the resulting image contains only pixels with a gray value of 0 and a gray value of 255. pixel.
  • Image smoothing processing is performed on the image to be processed after the binarization processing, and the number of times of image smoothing processing may be a preset number of times, and the preset number of times may be customized.
  • image smoothing is performed once to obtain the image after the first processing, and then image smoothing is performed on the image after the first processing to obtain the image after the second processing
  • image smoothing processing is performed on the image after the second processing to obtain the image after the third processing
  • the image after the third processing is the image after the third image smoothing processing.
  • the to-be-processed image after the binarization process is a binarized image
  • performing image smoothing processing on the to-be-processed image after binarization processing is to perform image smoothing processing on the binarized image, and then obtain a smooth image.
  • image smoothing it traverses the pixels in the image to be processed after binarization, and for each pixel, detects whether the gray values of adjacent pixels of the pixel are the same, If they are not the same, the sum of the gray values of adjacent pixels is calculated, and the calculated sum is divided by the number of adjacent pixels to obtain an average value.
  • the average value or a value close to the average value is used as the pixel
  • the gray value of the point may be a value obtained by rounding up the average value, or a value obtained after rounding down the average value.
  • the adjacent pixels of a pixel include pixel 1 and pixel 2, where the gray value of pixel 1 is 0 and the gray value of pixel 2 is 255, based on pixel 1 and pixel 2
  • the average value is 127.5, and 128 can be used as the gray value of the pixel.
  • image smoothing can also be achieved through Gaussian filtering, median filtering, and so on. This embodiment of the present application does not limit this.
  • pixels with other gray values are also included.
  • the gray values of pixels other than the first gray value and the second gray value can be set as the first gray value.
  • the obtained image contains only the first gray value
  • the pixels of the gray value and the second gray value that is, the obtained image contains only pixels of black and white colors, can be determined as the binary image to be processed.
  • the above image to be processed after image smoothing may be referred to as a smooth image, and pixels of other gray values in the smooth image except for the first gray value and the second gray value may be referred to as special pixels.
  • the gray value of the special pixel in the smoothed image can be set as the first gray value to obtain a binary image to be processed that only contains pixels of black and white colors.
  • the image to be processed after image smoothing also includes pixels with a gray value of 128.
  • the gray value of the dot is set to a gray value of 0, and the resulting image containing only pixels with gray values of 0 and 255 is determined as a binary image to be processed.
  • S102 Based on the pixels of the second gray value, determine the target pixels by the flood filling algorithm.
  • the flood filling algorithm starts from a pixel to find other pixels in the connected domain where the pixel is located, and then identifies the connected domain.
  • all pixels in the area composed of pixels with the second gray value can be determined.
  • the pixel determined here is the target pixel of the same connected domain.
  • the pixel point of the second gray value is selected as the starting pixel point from the binary image to be processed.
  • the pixels of the second gray value are pixels of the non-contour image area. It can be considered that the pixels of the second gray value are pixels in the connected domain of the binary image to be processed. When the to-be-processed binary image contains multiple connected domains, the selected starting pixel can be any pixel in any connected domain.
  • the pixels in the binary image to be processed are traversed according to a preset sequence, and the pixels of the second gray value traversed for the first time are determined as starting pixels.
  • the preset order can be customized.
  • the preset order can be from left to right, top to bottom, or from right to left, top to bottom.
  • the preset order can also be other custom orders, here Not limited.
  • the starting pixel determined according to the preset order may be regarded as a pixel adjacent to the boundary in a connected domain.
  • the target pixel After selecting the starting pixel from the binary image to be processed, starting from the starting pixel, the target pixel is determined by the flood filling algorithm, and the gray value of the target pixel is set to the preset gray value .
  • the second gray value adjacent to the starting pixel is determined by the flood filling algorithm A pixel is used as a target pixel, and the gray value of the target pixel is set to a preset gray value.
  • the target pixel point is adjacent to the starting pixel point, and the gray values of the target pixel point and the starting pixel point are the second gray value, therefore, it can be determined that the target pixel point and the starting pixel point are pixels in the same connected domain point.
  • the gray value of the target pixel is set to the preset gray value, it can be considered that the pixel of the preset gray value is the pixel of the same connected domain.
  • the preset grayscale value is other grayscale values than the first grayscale value and the second grayscale value, and the preset grayscale value may be customized.
  • the gray value of the traversed pixel By setting the gray value of the traversed pixel to the pixel of the preset gray value, it can be distinguished from other pixels of the second gray value that have not been traversed.
  • the preset gray value is 128, the pixels traversed by the flood filling algorithm are all pixels with a gray value of 255, and the gray value of these traversed pixels is set to 128, then the flood is completed After filling the algorithm, the resulting image includes pixels with gray values of 0, 255, and 128. Among them, pixels with a gray value of 128 are pixels in the same connected domain, and pixels with a gray value of 255 are Pixels that are not traversed in other connected domains. Record the pixels with the gray value of 128, that is, record the target pixels in the same connected domain, and then determine the connected domain where the target pixels are located.
  • the starting pixel is used as the target pixel, and the gray value of the target pixel is set to the preset gray value, and the adjacent pixel is detected. Whether the neighbor pixel is the second gray value.
  • the way to search for neighboring pixels adjacent to the starting pixel may be a four-way connected method, that is, starting from the starting pixel, and searching in four directions of up, down, left, and right respectively.
  • the way to search for neighboring pixels adjacent to the starting pixel can also be an eight-way connected method, that is, starting from the starting pixel, from the top, bottom, left, right, top left, bottom left, top right, bottom right eight The directions are searched separately.
  • other methods may be used to search for neighboring pixels adjacent to the starting pixel, which is not limited herein.
  • the neighbor pixel is detected as the second gray value, it can be determined that the neighbor pixel and the target pixel belong to the same connected domain, then the gray value of the neighbor pixel can be set to the preset gray value, and the The neighbor pixel is used as the target pixel, and returns to the step of detecting whether the gray value of the neighbor pixel adjacent to the target pixel is the second gray value until the gray value of the neighbor pixel adjacent to the target pixel is detected The degree value is not the second gray value.
  • the current target pixel is the pixel adjacent to the contour image area, that is, it has traversed to the boundary of the connected domain where the starting pixel is located , Has traversed all pixels in a connected domain.
  • the gray value of the neighboring pixel point is set to the preset gray value, and then, the neighboring pixel point is used as the target pixel point to continue the detection Whether the gray value of the neighboring pixel adjacent to the target pixel is the second gray value to avoid missing pixels in a connected domain.
  • the recorded target pixels belong to the same connected domain, that is to say, the recorded target pixels are pixels within a connected domain.
  • the above steps S102-S103 can be performed for each connected domain separately, and then the target pixel in each connected domain is recorded.
  • the correspondence between the identifier of the connected domain and the coordinates of the pixel can be recorded, wherein the correspondence between the identifier and the coordinate indicates that the pixel at the coordinate is among the pixels included in the connected domain characterized by the identifier One pixel. Therefore, the correspondence between the identification and the coordinates is a one-to-many correspondence, that is, a connected domain contains multiple pixels.
  • the identifier 1 corresponds to the coordinates (1,1) and (1,2), indicating that the pixel at the coordinate (1,1) and the pixel at the coordinate (1,2) belong to the connected domain represented by the identifier 1.
  • the gray values of all pixels in the connected domain are preset gray values . That is to say, the pixels of the preset gray value in the image at this time belong to the pixels in the same connected domain.
  • the gray of the pixels of the preset gray value The degree value is set to the first gray value, which is used to identify the connected domain, indicating that the connected domain has been identified.
  • the gray value of the pixel point of the preset gray value is set as the first gray value, and the obtained image may be called a modified image.
  • the resulting modified image still only contains the pixel point of the first gray value and the pixel point of the second gray value, Determine the modified image as the to-be-processed binarized image, and select the pixel point of the second gray value from the to-be-processed binarized image as the starting pixel point until the to-be-processed binarized image does not exist The pixel of the second gray value. At this point, the recognition of all connected domains in the image to be processed is completed.
  • the image to be processed is binarized to obtain the binarized image to be processed.
  • the target pixel is determined by the flood filling algorithm, and the target is recorded pixel.
  • the image to be processed is binarized to obtain the image to be processed.
  • the image to be processed is outlined by the first gray value and the second gray value.
  • the image area is distinguished from the non-contour image area.
  • all pixels in the area composed of pixels with the second gray value can be determined by the flood filling algorithm, that is, those belonging to the same connected domain can be determined
  • Target pixels are recorded and recorded, so that the connected domains in the image can be identified without manual participation, which saves human resources and solves the problem that it takes a long time and wastes human resources to manually identify the connected domains in the image.
  • an embodiment of the present application further provides an image processing apparatus.
  • the image processing apparatus includes:
  • the processing module 210 is configured to perform binarization processing on the image to be processed to obtain a binarized image to be processed; wherein the binarized image to be processed includes: a contour image area and a non-contour image area, and pixels of the contour image area The gray value is the first gray value, and the gray value of the pixels in the non-contour image area is the second gray value;
  • the first determining module 220 is used to determine the target pixel point through the flood filling algorithm based on the pixel point of the second gray value;
  • the recording module 230 is used to record the target pixel.
  • the first determining module 220 may be specifically used to:
  • the target pixel is determined by the flood filling algorithm, and the gray value of the target pixel is set to the preset gray value.
  • the device may further include:
  • the setting module is used to set the gray value of the pixel point of the preset gray value to the first gray value after recording the target pixel point of the preset gray value to obtain the modified image;
  • the second determining module is used to determine the modified image as a binary image to be processed, and triggers the first determining module 220 to perform selecting a pixel point of a second gray value from the binary image to be processed as a starting point The steps of starting pixels.
  • the first determining module 220 may be specifically used to:
  • the first determining module 220 may be specifically used to:
  • the pixel point of the second gray value traversed for the first time is determined as the starting pixel point.
  • the processing module 210 is specifically used to:
  • the image to be processed is binarized to obtain the binarized image to be processed.
  • the target pixel is determined by the flood filling algorithm, and the target is recorded pixel.
  • the image to be processed is binarized to obtain the image to be processed.
  • the image to be processed is outlined by the first gray value and the second gray value.
  • the image area is distinguished from the non-contour image area.
  • all pixels in the area composed of pixels with the second gray value can be determined by the flood filling algorithm, that is, those belonging to the same connected domain can be determined
  • Target pixels are recorded and recorded, so that the connected domains in the image can be identified without manual participation, which saves human resources and solves the problem that it takes a long time and wastes human resources to manually identify the connected domains in the image.
  • an embodiment of the present application further provides an electronic device, as shown in FIG. 3, which includes a processor 310, a communication interface 320, a memory 330, and a communication bus 340.
  • the interface 320 and the memory 330 complete communication with each other through the communication bus 340;
  • Memory 330 is used to store computer programs
  • Binary processing is performed on the image to be processed to obtain a binary image to be processed; wherein the binary image to be processed includes: a contour image area and a non-contour image area, and the gray value of the pixels in the contour image area is the first Gray value, the gray value of the pixels in the non-contour image area is the second gray value;
  • the target pixels are determined by the flood filling algorithm
  • the image to be processed is binarized to obtain the binarized image to be processed.
  • the target pixel is determined by the flood filling algorithm, and the target is recorded pixel.
  • the image to be processed is binarized to obtain the image to be processed.
  • the image to be processed is outlined by the first gray value and the second gray value.
  • the image area is distinguished from the non-contour image area.
  • all pixels in the area composed of pixels with the second gray value can be determined by the flood filling algorithm, that is, those belonging to the same connected domain can be determined
  • Target pixels are recorded and recorded, so that the connected domains in the image can be identified without manual participation, which saves human resources and solves the problem that it takes a long time and wastes human resources to manually identify the connected domains in the image.
  • the communication bus mentioned in the above electronic equipment may be a peripheral component interconnection standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard structure (Extended Industry Standard Architecture, EISA) bus, etc.
  • PCI peripheral component interconnection standard
  • EISA Extended Industry Standard Architecture
  • the communication bus can be divided into an address bus, a data bus, and a control bus. For ease of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the electronic device and other devices.
  • the memory may include random access memory (Random Access Memory, RAM), or non-volatile memory (Non-Volatile Memory, NVM), for example, at least one disk memory.
  • RAM Random Access Memory
  • NVM Non-Volatile Memory
  • the memory may also be at least one storage device located away from the foregoing processor.
  • the processor can be a general-purpose processor, including a central processor (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), an application specific integrated circuit ( Application Specific (Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • CPU Central Processing Unit
  • NP Network Processor
  • DSP Digital Signal Processing
  • ASIC Application Specific
  • FPGA Field-Programmable Gate Array
  • the embodiments of the present application further provide a machine-readable storage medium in which a computer program is stored, and when the computer program is executed by a processor, any of the above-mentioned images is realized Processing method steps.
  • an embodiment of the present application further provides a computer program that implements any of the above image processing method steps when the computer program is executed by a processor.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

一种图像处理方法及装置,所述方法包括:对待处理图像进行二值化处理,获得待处理二值化图像(S101),基于第二灰度值的像素点,通过漫水填充算法确定目标像素点(S102),并记录目标像素点(S103)。该方法将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下可以对图像中的连通域进行识别,节省人力资源。

Description

一种图像处理方法及装置
本申请要求于2018年12月29日提交中国专利局、申请号为201811640194.6发明名称为“一种图像处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及图像处理技术领域,特别是涉及一种图像处理方法及装置。
背景技术
图像中的连通域是指图像中灰度值相同且位置相邻的像素点所组成的图像区域。连通域的识别在图像处理中应用较广泛,例如车牌识别、拼图类游戏中轮廓图的绘制等图像处理中均应用了连通域的识别。
尤其在拼图类游戏中,大量使用由白色像素点和黑色像素点组成的轮廓图,玩家将轮廓图中各白色像素点组成的连通域填充上不同的颜色,进而达到将由白色像素点和黑色像素点组成的轮廓图变成彩色填充图的目的。
然而,拼图类游戏中所采用的轮廓图是根据实际拍摄的彩色图所得到的。具体地,游戏制作人员通过人工识图的方式,识别实际拍摄的彩色图中的连通域,并在由白色像素点组成的图像上手绘实际拍摄的彩色图中的连通域边界,进而得到由白色像素点和黑色像素点组成的轮廓图。这样的轮廓图的绘制过程中,连通域的识别不仅耗时长,而且浪费人力资源。
发明内容
本申请实施例的目的在于提供一种图像处理方法及装置,以解决人工识别图像中的连通域耗时长且浪费人力资源的问题。具体技术方案如下:
第一方面,本申请实施例提供了一种图像处理方法,所述方法包括:
对待处理图像进行二值化处理,获得待处理二值化图像;其中,所述待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,所述轮廓图像区域中的像素点的灰度值为第一灰度值,所述非轮廓图像区域中的像素点的灰度值为第二灰度值;
基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点;
记录所述目标像素点。
可选地,所述基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点,包括:
从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点;
从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值。
可选地,在记录所述预设灰度值的目标像素点之后,所述方法还包括:
将所述预设灰度值的像素点的灰度值设置为所述第一灰度值,得到修改后图像;
将所述修改后图像确定为待处理二值化图像,并返回执行所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点的步骤。
可选地,所述从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值,包括:
将所述起始像素点作为目标像素点,并将所述目标像素点的灰度值设置为预设灰度值;
检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值;
如果是,将所述相邻像素点的灰度值设置为所述预设灰度值,将所述相邻像素点作为目标像素点,并返回执行所述检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值的步骤。
可选地,所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点,包括:
按照预设顺序,对所述待处理二值化图像中的像素点进行遍历;
将第一次遍历到的所述第二灰度值的像素点确定为起始像素点。
可选地,所述对待处理图像进行二值化处理,获得待处理二值化图像, 包括:
将待处理图像进行二值化处理,得到二值化图像;
对所述二值化图像进行预设次数的图像平滑处理,得到平滑图像;
将所述平滑图像中的特殊像素点的灰度值设置为所述第一灰度值,得到待处理二值化图像,其中,所述特殊像素点为除所述第一灰度值和所述第二灰度值以外的其他灰度值的像素点。
第二方面,本申请实施例提供了一种图像处理装置,所述装置包括:
处理模块,用于对待处理图像进行二值化处理,获得待处理二值化图像;其中,所述待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,所述轮廓图像区域中的像素点的灰度值为第一灰度值,所述非轮廓图像区域中的像素点的灰度值为第二灰度值;
第一确定模块,用于基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点;
记录模块,用于记录所述目标像素点。
可选地,所述第一确定模块具体用于:
从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点;
从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值。
可选地,所述装置还包括:
设置模块,用于在记录所述预设灰度值的目标像素点之后,将所述预设灰度值的像素点的灰度值设置为所述第一灰度值,得到修改后图像;
第二确定模块,用于将所述修改后图像确定为待处理二值化图像,并触发所述第一确定模块用于执行所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点的步骤。
可选地,所述第一确定模块具体用于:
将所述起始像素点作为目标像素点,并将所述目标像素点的灰度值设置为预设灰度值;
检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值;
如果是,将所述相邻像素点的灰度值设置为所述预设灰度值,将所述相邻像素点作为目标像素点,并返回执行所述检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值的步骤。
可选地,所述第一确定模块具体用于:
按照预设顺序,对所述待处理二值化图像中的像素点进行遍历;
将第一次遍历到的所述第二灰度值的像素点确定为起始像素点。
可选地,所述处理模块具体用于:
将待处理图像进行二值化处理,得到二值化图像;
对所述二值化图像进行预设次数的图像平滑处理,得到平滑图像;
将所述平滑图像中的特殊像素点的灰度值设置为所述第一灰度值,得到待处理二值化图像,其中,所述特殊像素点为除所述第一灰度值和所述第二灰度值以外的其他灰度值的像素点。
第三方面,本申请实施例提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;
存储器,用于存放计算机程序;
处理器,用于执行存储器上所存放的程序时,实现上述任一所述的图像处理方法步骤。
第四方面,本申请实施例提供了一种机器可读存储介质,所述机器可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现上述任一所述的图像处理方法步骤。
第五方面,本申请实施例提供了一种计算机程序,所述计算机程序被处 理器执行时实现上述任一所述的图像处理方法步骤。
本申请实施例提供的技术方案中,对待处理图像进行二值化处理,获得待处理二值化图像,基于第二灰度值的像素点,通过漫水填充算法确定目标像素点,并记录目标像素点。通过本申请实施例提供的技术方案,将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法可以确定由第二灰度值的像素点组成的区域中所有像素点,即可以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下对图像中的连通域进行识别,节省了人力资源,解决了人工识别图像中的连通域耗长时且浪费人力资源的问题。
附图说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的图像处理方法的一种流程示意图;
图2为本申请实施例提供的图像处理装置的一种结构示意图;
图3为本申请实施例提供的电子设备的一种结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为了解决人工识别图像中的连通域耗时长且浪费人力资源的问题,本申请实施例提供了一种图像处理方法及装置,其中,该图像处理方法包括:
对待处理图像进行二值化处理,获得待处理二值化图像;其中,待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,轮廓图像区域中的像素点的灰度值为第一灰度值,非轮廓图像区域中的像素点的灰度值为第二灰度 值;
基于第二灰度值的像素点,通过漫水填充算法确定目标像素点;
记录目标像素点。
本申请实施例提供的技术方案中,对待处理图像进行二值化处理,获得待处理二值化图像,基于第二灰度值的像素点,通过漫水填充算法确定目标像素点,并记录目标像素点。通过本申请实施例提供的技术方案,将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法可以确定由第二灰度值的像素点组成的区域中所有像素点,即可以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下对图像中的连通域进行识别,节省了人力资源,解决了人工识别图像中的连通域耗长时且浪费人力资源的问题。
下面首先对本申请实施例提供的一种图像处理方法进行介绍。本申请实施例提供的一种图像处理方法,如图1所示,包括如下步骤。
S101,对待处理图像进行二值化处理,获得待处理二值化图像。
其中,待处理图像可以是彩色图像、灰度图像等任一种图像。当待处理图像为彩色图像时的一种实现方式中,可以将彩色的待处理图像转换为单通道的灰度图。其中,可以是通过开源计算机视觉库(Open Source Computer Vision Library,OpenCV)将彩色的待处理图像转换为单通道的灰度图。在得到灰度图之后,对灰度图进行二值化处理,进而可以得到二值化图像,所得到的二值化图像中仅包括黑白两种颜色。例如仅包含灰度值为0的像素点和灰度值为255的像素点。
另外,在进行二值化处理之后,可以对所得到的二值化图像进行降噪处理,以提高二值化图像的质量。
其中,待处理二值化图像包括:轮廓图像区域和非轮廓图像区域,轮廓图像区域中的像素点的灰度值为第一灰度值,非轮廓图像区域中的像素点的灰度值为第二灰度值。
轮廓图像区域用于凸显出待处理二值化图像中人、物等目标的轮廓。可以认为,轮廓图像区域由灰度值相同的相邻像素点形成的线条组成,各线条组合形成凸显目标的轮廓。非轮廓图像区域即为待处理二值化图像中除轮廓图像区域以外的区域。
一个示例中,基于待处理二值化图像中仅包含灰度值为0的像素点和灰度值为255的像素点,针对第一灰度值和第二灰度值,可以包括以下两种情况:第一种情况,第一灰度值为0,第二灰度值为255;第二种情况,第一灰度值为255,第二灰度值为0。
针对第一种情况,非轮廓图像区域为白色像素点组成的区域,轮廓图像区域为黑色像素点组成的区域。此种情况下可以认为,待处理二值化图像中以白色为底色,用黑色的线条凸显目标的轮廓。针对第二种情况,非轮廓图像区域为黑色像素点组成的区域,轮廓图像区域为白色像素点组成的区域。此种情况下可以认为,待处理二值化图像中以黑色为底色,用白色的线条凸显目标的轮廓。
本申请实施例中以第一种情况为例进行说明。
一种实施方式中,在对待处理图像进行二值化处理之后,所得到的图像为二值化图像,即所得到的图像中仅包含灰度值为0的像素点和灰度值为255的像素点。对经过二值化处理后的待处理图像进行图像平滑处理,进行图像平滑处理的次数可以是预设次数,该预设次数可以是自定义的。
例如,预设次数为3次时,则先进行一次图像平滑处理,可以得到第一次处理后的图像,再对该第一次处理后的图像进行图像平滑处理,得到第二次处理后的图像,最后再对该第二次处理后的图像进行图像平滑处理,得到第三次处理后的图像,该第三次处理后的图像即为经过三次图像平滑处理后的图像。
上述经过二值化处理后的待处理图像为二值化图像,对经过二值化处理后的待处理图像进行图像平滑处理即为,对二值化图像进行图像平滑处理,进而得到平滑图像。
其中,图像平滑处理的一种实现方式中,遍历经过二值化处理后的待处 理图像中的像素点,针对每一像素点,检测该像素点的相邻像素点的灰度值是否相同,若不相同,则计算相邻像素点的灰度值的和,将所计算出的和除以相邻像素点的数量,即可以得到均值,将该均值或者与该均值相近的值作为该像素点的灰度值。其中,与该均值相近的值可以为对该均值进行向上取整后得到的值,也可以为对该均值进行向下取整后得到的值。
例如,一个像素点的相邻像素点包括像素点1和像素点2,其中,像素点1的灰度值为0,像素点2的灰度值为255,基于像素点1和像素点2的灰度值,可以得到均值为127.5,则可以将128作为像素点的灰度值。
除了上述方式实现图像平滑处理以外,图像平滑处理还可以通过高斯滤波、中值滤波等方式实现。本申请实施例对此不进行限定。
在经过图像平滑处理后的待处理图像中,除了灰度值为0和255的像素点以外,还包括其他灰度值的像素点。此时,可以将除第一灰度值和第二灰度值以外的其他灰度值的像素点的灰度值设置为第一灰度值,基于此,所得到的图像中仅包含第一灰度值和第二灰度值的像素点,即所得到的图像仅包含黑白两种颜色的像素点,可以将所得到的图像确定为待处理二值化图像。
上述经过图像平滑处理后的待处理图像可称为平滑图像,平滑图像中除第一灰度值和第二灰度值以外的其他灰度值的像素点可称为特殊像素点,在得到平滑图像后,可将平滑图像中特殊像素点的灰度值设置为第一灰度值,得到仅包含黑白两种颜色的像素点的待处理二值化图像。
例如,第一灰度值为0,第二灰度值为255,在经过图像平滑处理后的待处理图像中还包括灰度值为128的像素点,则可以将灰度值为128的像素点的灰度值设置为灰度值为0,并将所得到的仅包含灰度值0和255的像素点的图像确定为待处理二值化图像。
S102,基于第二灰度值的像素点,通过漫水填充算法确定目标像素点。
其中,漫水填充算法是从一个像素点开始找到该像素点所在连通域内的其他像素点,进而识别出该连通域。
本申请实施例中,通过漫水填充算法,可确定由第二灰度值的像素点组成的区域中所有像素点。这里所确定的像素点即为同一连通域的目标像素点。
一种实施方式中,从待处理二值化图像中选取第二灰度值的像素点,作为起始像素点。
第二灰度值的像素点为非轮廓图像区域的像素点。可以认为,第二灰度值的像素点为待处理二值化图像的连通域中的像素点。当待处理二值化图像中包含多个连通域时,所选取的起始像素点可以是任一连通域中的任一像素点。
一种实现方式中,按照预设顺序,对待处理二值化图像中的像素点进行遍历,并将第一次遍历到的第二灰度值的像素点确定为起始像素点。
其中,预设顺序可以是自定义设定的。预设顺序可以是按照从左至右、从上至下的顺序,还可以是按照从右至左、从上至下的顺序,当然,预设顺序还可以是自定义的其他顺序,在此不作限定。
本申请实施例中,按照预设顺确定的起始像素点可以认为是一连通域中与边界相邻的一个像素点。
按照预设顺序遍历待处理二值化图像中的像素点,可以避免遗漏第二灰度值的像素点,进而避免遗漏待处理二值化图像中的连通域,使得待处理二值化图像中的每一连通域均能被识别。
在从待处理二值化图像中选取起始像素点之后,从起始像素点开始,通过漫水填充算法确定目标像素点,并将该目标像素点的灰度值设置为预设灰度值。
本申请实施例中,在从待处理二值化图像中选取起始像素点之后,从起始像素点开始,通过漫水填充算法,确定与起始像素点相邻的第二灰度值的像素点,作为目标像素点,并将该目标像素点的灰度值设置为预设灰度值。
目标像素点与起始像素点相邻,且目标像素点与起始像素点的灰度值均为第二灰度值,因此,可确定目标像素点与起始像素点为同一连通域内的像素点。将目标像素点的灰度值设置为预设灰度值后,可以认为,预设灰度值的像素点为同一连通域的像素点。
其中,预设灰度值为第一灰度值和第二灰度值以外的其他灰度值,该预 设灰度值可以是自定义设定的。通过将遍历到的像素点的灰度值设置为预设灰度值的像素点,以区分于其他未被遍历到的第二灰度值的像素点。
例如,预设灰度值为128,利用漫水填充算法遍历到的像素点均为灰度值255的像素点,将这些遍历到的像素点的灰度值设置为128,则在完成漫水填充算法之后,所得到的图像中包括灰度值为0、255以及128的像素点,其中,灰度值为128的像素点为同一连通域内的像素点,灰度值为255的像素点为其他连通域内未被遍历到的像素点。记录灰度值为128的像素点,即记录同一连通域内的目标像素点,进而确定出目标像素点所在的连通域。
一种实现方式中,从起始像素点开始,将起始像素点作为目标像素点,并将目标像素点的灰度值设置为预设灰度值,并检测与该目标像素点相邻的邻居像素点是否为第二灰度值。
其中,搜索与起始像素点相邻的邻居像素点的方式可以是四向连通的方式,即从起始像素点出发,从上、下、左、右四个方向分别进行搜索。搜索与起始像素点相邻的邻居像素点的方式还可以是八向连通的方式,即从起始像素点出发,从上、下、左、右、左上、左下、右上、右下八个方向分别进行搜索。除了上述两种方式以外,还可以是其他方式的搜索与起始像素点相邻的邻居像素点,在此不作限定。
若检测到邻居像素点为第二灰度值,可以确定该邻居像素点与目标像素点属于同一连通域,则可以将该邻居像素点的灰度值设置为预设灰度值,并将该邻居像素点作为目标像素点,返回执行检测与目标像素点相邻的邻居像素点的灰度值是否为第二灰度值的步骤,直至检测出与目标像素点相邻的邻居像素点的灰度值均不是第二灰度值为止。
若检测到邻居像素点的灰度值均不是第二灰度值,则可以确定当前的目标像素点为与轮廓图像区域相邻的像素点,即已遍历至起始像素点所在连通域的边界,已遍历完一个连通域内的所有像素点。
本申请实施例中,检测到邻居像素点为第二灰度值时,将该邻居像素点的灰度值设置为预设灰度值,之后,将该邻居像素点作为目标像素点,继续检测与目标像素点相邻的邻居像素点的灰度值是否为第二灰度值,避免遗漏 一连通域中像素点。
S103,记录目标像素点。
在遍历完一个连通域内的所有像素点后,记录该连通域内的目标像素点。所记录的目标像素点属于同一连通域,也就是说,所记录的目标像素点即为一个连通域内的像素点。
本申请实施例中,若待处理二值化图像中包括多个连通域,则可以针对每一连通域,分别执行上述步骤S102-S103,进而记录每一连通域内的目标像素点。
一种实现方式中,可以记录连通域的标识与像素点的坐标的对应关系,其中,标识与坐标的对应关系表示该坐标处的像素点为该标识所表征的连通域所包含的像素点中的一个像素点。因此,标识与坐标的对应关系是一对多的对应关系,即一个连通域是包含多个像素点的。例如,标识1对应坐标(1,1)和(1,2),表示坐标(1,1)处的像素点和坐标(1,2)处的像素点均属于标识1所表征的连通域。
一种实施方式中,在完成漫水填充算法之后,即已遍历完起始像素点所在的连通域内的所有像素点,且该连通域内的所有像素点的灰度值均为预设灰度值。也就是说,此时的图像中预设灰度值的像素点均属于同一连通域内的像素点,在对预设灰度值的像素点记录之后,将预设灰度值的像素点的灰度值设置为第一灰度值,用于对该连通域进行标识,表示该连通域已被识别。
其中,将预设灰度值的像素点的灰度值设置为第一灰度值,得到图像可以称为修改后图像。
将预设灰度值的像素点的灰度值设置为第一灰度值之后,所得到的修改后图像中仍只包含第一灰度值的像素点和第二灰度值的像素点,将该修改后图像确定为待处理二值化图像,并重新从待处理二值化图像中选取第二灰度值的像素点,作为起始像素点,直至待处理二值化图像中不存在第二灰度值的像素点。此时,即完成对待处理图像中所有连通域的识别。
本申请实施例提供的技术方案中,对待处理图像进行二值化处理,获得待处理二值化图像,基于第二灰度值的像素点,通过漫水填充算法确定目标 像素点,并记录目标像素点。通过本申请实施例提供的技术方案,将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法可以确定由第二灰度值的像素点组成的区域中所有像素点,即可以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下可以对图像中的连通域进行识别,节省了人力资源,解决了人工识别图像中的连通域耗长时且浪费人力资源的问题。
相应于上述图像处理方法实施例,本申请实施例还提供了一种图像处理装置,如图2所示,该图像处理装置包括:
处理模块210,用于对待处理图像进行二值化处理,获得待处理二值化图像;其中,待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,轮廓图像区域中的像素点的灰度值为第一灰度值,非轮廓图像区域中的像素点的灰度值为第二灰度值;
第一确定模块220,用于基于第二灰度值的像素点,通过漫水填充算法确定目标像素点;
记录模块230,用于记录目标像素点。
一种实施方式中,第一确定模块220具体可以用于:
从待处理二值化图像中选取第二灰度值的像素点,作为起始像素点;
从起始像素点开始,通过漫水填充算法确定目标像素点,并将目标像素点的灰度值设置为预设灰度值。
一种实施方式中,该装置还可以包括:
设置模块,用于在记录预设灰度值的目标像素点之后,将预设灰度值的像素点的灰度值设置为第一灰度值,得到修改后图像;
第二确定模块,用于将修改后图像确定为待处理二值化图像,并触发第一确定模块220用于执行从待处理二值化图像中选取第二灰度值的像素点,作为起始像素点的步骤。
一种实施方式中,第一确定模块220具体可以用于:
将起始像素点作为目标像素点,并将目标像素点的灰度值设置为预设灰度值;
检测与目标像素点相邻的邻居像素点的灰度值是否为第二灰度值;
如果是,将相邻像素点的灰度值设置为预设灰度值,将相邻像素点作为目标像素点,并返回执行检测与目标像素点相邻的邻居像素点的灰度值是否为第二灰度值的步骤。
一种实施方式中,第一确定模块220具体可以用于:
按照预设顺序,对待处理二值化图像中的像素点进行遍历;
将第一次遍历到的第二灰度值的像素点确定为起始像素点。
一种实施方式中,处理模块210具体用于:
将待处理图像进行二值化处理,得到二值化图像;
对二值化图像进行预设次数的图像平滑处理,得到平滑图像;
将平滑图像中的特殊像素点的灰度值设置为第一灰度值,得到待处理二值化图像,其中,特殊像素点为除第一灰度值和第二灰度值以外的其他灰度值的像素点。
本申请实施例提供的技术方案中,对待处理图像进行二值化处理,获得待处理二值化图像,基于第二灰度值的像素点,通过漫水填充算法确定目标像素点,并记录目标像素点。通过本申请实施例提供的技术方案,将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法可以确定由第二灰度值的像素点组成的区域中所有像素点,即可以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下可以对图像中的连通域进行识别,节省了人力资源,解决了人工识别图像中的连通域耗长时且浪费人力资源的问题。
相应于上述图像处理方法实施例,本申请实施例还提供了一种电子设备,如图3所示,包括处理器310、通信接口320、存储器330和通信总线340,其中,处理器310、通信接口320、存储器330通过通信总线340完成相互间的通信;
存储器330,用于存放计算机程序;
处理器310,用于执行存储器330上所存放的程序时,实现如下步骤:
对待处理图像进行二值化处理,获得待处理二值化图像;其中,待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,轮廓图像区域中的像素点的灰度值为第一灰度值,非轮廓图像区域中的像素点的灰度值为第二灰度值;
基于第二灰度值的像素点,通过漫水填充算法确定目标像素点;
记录目标像素点。
本申请实施例提供的技术方案中,对待处理图像进行二值化处理,获得待处理二值化图像,基于第二灰度值的像素点,通过漫水填充算法确定目标像素点,并记录目标像素点。通过本申请实施例提供的技术方案,将待处理图像进行二值化处理后得到待处理二值化图像,该待处理二值化图像中通过第一灰度值和第二灰度值将轮廓图像区域与非轮廓图像区域区分开,对于每一个非轮廓图像区域,通过漫水填充算法可以确定由第二灰度值的像素点组成的区域中所有像素点,即可以确定属于同一连通域的目标像素点并记录,进而在不需要人工参与的情况下可以对图像中的连通域进行识别,节省了人力资源,解决了人工识别图像中的连通域耗长时且浪费人力资源的问题。
上述电子设备提到的通信总线可以是外设部件互连标准(Peripheral Component Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
通信接口用于上述电子设备与其他设备之间的通信。
存储器可以包括随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器(Non-Volatile Memory,NVM),例如至少一个磁盘存储器。可选的,存储器还可以是至少一个位于远离前述处理器的存储装置。
处理器可以是通用处理器,包括中央处理器(Central Processing Unit, CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。
相应于上述图像处理方法实施例,本申请实施例还提供了一种机器可读存储介质,机器可读存储介质内存储有计算机程序,计算机程序被处理器执行时实现上述任一所述的图像处理方法步骤。
相应于上述图像处理方法实施例,本申请实施例还提供了一种计算机程序,计算机程序被处理器执行时实现上述任一所述的图像处理方法步骤。
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于图像处理装置、电子设备、机器可读存储介质及计算机程序实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见图像处理方法实施例的部分说明即可。
以上所述仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和原则之内所作的任何修改、等同替换、改进等,均包含在本申请的保护范围内。

Claims (15)

  1. 一种图像处理方法,其特征在于,所述方法包括:
    对待处理图像进行二值化处理,获得待处理二值化图像;其中,所述待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,所述轮廓图像区域中的像素点的灰度值为第一灰度值,所述非轮廓图像区域中的像素点的灰度值为第二灰度值;
    基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点;
    记录所述目标像素点。
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点,包括:
    从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点;
    从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值。
  3. 根据权利要求2所述的方法,其特征在于,在记录所述预设灰度值的目标像素点之后,所述方法还包括:
    将所述预设灰度值的像素点的灰度值设置为所述第一灰度值,得到修改后图像;
    将所述修改后图像确定为待处理二值化图像,并返回执行所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点的步骤。
  4. 根据权利要求2所述的方法,其特征在于,所述从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值,包括:
    将所述起始像素点作为目标像素点,并将所述目标像素点的灰度值设置为预设灰度值;
    检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值;
    如果是,将所述相邻像素点的灰度值设置为所述预设灰度值,并将所述相邻像素点作为目标像素点,并返回执行所述检测与所述目标像素点相邻的 邻居像素点的灰度值是否为所述第二灰度值的步骤。
  5. 根据权利要求2所述的方法,其特征在于,所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点,包括:
    按照预设顺序,对所述待处理二值化图像中的像素点进行遍历;
    将第一次遍历到的所述第二灰度值的像素点确定为起始像素点。
  6. 根据权利要求1所述的方法,其特征在于,所述对待处理图像进行二值化处理,获得待处理二值化图像,包括:
    将待处理图像进行二值化处理,得到二值化图像;
    对所述二值化图像进行预设次数的图像平滑处理,得到平滑图像;
    将所述平滑图像中的特殊像素点的灰度值设置为所述第一灰度值,得到待处理二值化图像,其中,所述特殊像素点为除所述第一灰度值和所述第二灰度值以外的其他灰度值的像素点。
  7. 一种图像处理装置,其特征在于,所述装置包括:
    处理模块,用于对待处理图像进行二值化处理,获得待处理二值化图像;其中,所述待处理二值化图像包括:轮廓图像区域与非轮廓图像区域,所述轮廓图像区域中的像素点的灰度值为第一灰度值,所述非轮廓图像区域中的像素点的灰度值为第二灰度值;
    第一确定模块,用于基于所述第二灰度值的像素点,通过漫水填充算法确定目标像素点;
    记录模块,用于记录所述目标像素点。
  8. 根据权利要求7所述的装置,其特征在于,所述第一确定模块具体用于:
    从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点;
    从所述起始像素点开始,通过漫水填充算法确定目标像素点,并将所述目标像素点的灰度值设置为预设灰度值。
  9. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    设置模块,用于在记录所述预设灰度值的目标像素点之后,将所述预设灰度值的像素点的灰度值设置为所述第一灰度值,得到修改后图像;
    第二确定模块,用于将所述修改后图像确定为待处理二值化图像,并触发所述第一确定模块用于执行所述从所述待处理二值化图像中选取所述第二灰度值的像素点,作为起始像素点的步骤。
  10. 根据权利要求8所述的装置,其特征在于,所述第一确定模块具体用于:
    将所述起始像素点作为目标像素点,并将所述目标像素点的灰度值设置为预设灰度值;
    检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值;
    如果是,将所述相邻像素点的灰度值设置为所述预设灰度值,将所述相邻像素点作为目标像素点,并返回执行所述检测与所述目标像素点相邻的邻居像素点的灰度值是否为所述第二灰度值的步骤。
  11. 根据权利要求8所述的装置,其特征在于,所述第一确定模块具体用于:
    按照预设顺序,对所述待处理二值化图像中的像素点进行遍历;
    将第一次遍历到的所述第二灰度值的像素点确定为起始像素点。
  12. 根据权利要求7所述的装置,其特征在于,所述处理模块具体用于:
    将待处理图像进行二值化处理,得到二值化图像;
    对所述二值化图像进行预设次数的图像平滑处理,得到平滑图像;
    将所述平滑图像中的特殊像素点的灰度值设置为所述第一灰度值,得到待处理二值化图像,其中,所述特殊像素点为除所述第一灰度值和所述第二灰度值以外的其他灰度值的像素点。
  13. 一种电子设备,其特征在于,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口、存储器通过通信总线完成相互间的通信;
    存储器,用于存放计算机程序;
    处理器,用于执行存储器上所存放的程序时,实现权利要求1-6任一所述的方法步骤。
  14. 一种机器可读存储介质,其特征在于,所述机器可读存储介质内存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1-6任一所 述的方法步骤。
  15. 一种计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-6任一所述的方法步骤。
PCT/CN2019/124599 2018-12-29 2019-12-11 一种图像处理方法及装置 WO2020135056A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811640194.6A CN109754379A (zh) 2018-12-29 2018-12-29 一种图像处理方法及装置
CN201811640194.6 2018-12-29

Publications (1)

Publication Number Publication Date
WO2020135056A1 true WO2020135056A1 (zh) 2020-07-02

Family

ID=66404424

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/124599 WO2020135056A1 (zh) 2018-12-29 2019-12-11 一种图像处理方法及装置

Country Status (2)

Country Link
CN (1) CN109754379A (zh)
WO (1) WO2020135056A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113506358A (zh) * 2021-07-15 2021-10-15 上海眼控科技股份有限公司 一种图像标注方法、装置、设备和存储介质
CN113888578A (zh) * 2021-09-26 2022-01-04 合肥高维数据技术有限公司 自适应加权阈值技术的二值化方法
CN115661119A (zh) * 2022-11-11 2023-01-31 北京鉴智科技有限公司 一种连通域的检索方法、装置和一种连通域检索器

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109754379A (zh) * 2018-12-29 2019-05-14 北京金山安全软件有限公司 一种图像处理方法及装置
CN110443820B (zh) * 2019-07-03 2023-07-14 平安科技(深圳)有限公司 一种图像处理方法以及装置
CN110969583A (zh) * 2019-09-11 2020-04-07 宁波江丰生物信息技术有限公司 一种图像背景处理方法及系统
CN111260759B (zh) * 2020-01-10 2023-02-24 北京金山安全软件有限公司 一种路径确定方法及装置
CN111583157B (zh) * 2020-05-13 2023-06-02 杭州睿琪软件有限公司 图像处理方法、系统及计算机可读存储介质
CN111753688B (zh) * 2020-06-12 2022-03-18 广州极飞科技股份有限公司 种植行中心线确定方法、装置、电子设备及存储介质
CN111767924B (zh) * 2020-07-03 2024-01-26 杭州睿琪软件有限公司 图像处理方法、图像处理装置、电子设备、存储介质
CN113688811B (zh) * 2021-10-26 2022-04-08 北京美摄网络科技有限公司 图像处理方法、装置、电子设备及存储介质
CN115147442B (zh) * 2022-06-06 2024-09-27 浙江大华技术股份有限公司 栅格图案的矢量化方法、移动终端、电子设备和介质
CN118230939A (zh) * 2024-03-22 2024-06-21 陕西省结核病防治院(陕西省第五人民医院) 一种基于肺结核超声造影图像的预测模型构建方法及系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281112A (zh) * 2008-04-30 2008-10-08 浙江理工大学 一种对网状粘连稻米的图像式自动分析方法
US20100061633A1 (en) * 2008-09-05 2010-03-11 Digital Business Processes, Inc. Method and Apparatus for Calculating the Background Color of an Image
CN108446706A (zh) * 2018-02-27 2018-08-24 西安交通大学 一种基于颜色主分量提取的磨粒材质自动识别方法
CN109754379A (zh) * 2018-12-29 2019-05-14 北京金山安全软件有限公司 一种图像处理方法及装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102324020B (zh) * 2011-09-02 2014-06-11 北京新媒传信科技有限公司 人体肤色区域的识别方法和装置
CN103544469B (zh) * 2013-07-24 2017-05-10 Tcl集团股份有限公司 一种基于掌心测距的指尖检测方法和装置
CN104375175B (zh) * 2013-08-15 2017-08-04 中国石油天然气集团公司 倾角传播法层位自动追踪方法
CN108694719B (zh) * 2017-04-05 2020-11-03 北京京东尚科信息技术有限公司 图像输出方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281112A (zh) * 2008-04-30 2008-10-08 浙江理工大学 一种对网状粘连稻米的图像式自动分析方法
US20100061633A1 (en) * 2008-09-05 2010-03-11 Digital Business Processes, Inc. Method and Apparatus for Calculating the Background Color of an Image
CN108446706A (zh) * 2018-02-27 2018-08-24 西安交通大学 一种基于颜色主分量提取的磨粒材质自动识别方法
CN109754379A (zh) * 2018-12-29 2019-05-14 北京金山安全软件有限公司 一种图像处理方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ZHI-QIANG FANG, XIAO SHU-HAO;XIONG HE-GEN;LI GONG-FA;: "Part product counting system based on machine vision and SVM", MANUFACTURING AUTOMATION, BEIJING INSTITUTE OF MACHINERY INDUSTRY AUTOMATION, MINISTRY OF MACHINERY, CN, vol. 40, no. 7, 1 July 2018 (2018-07-01), CN, pages 37 - 40,48, XP055716779, ISSN: 1009-0134 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113506358A (zh) * 2021-07-15 2021-10-15 上海眼控科技股份有限公司 一种图像标注方法、装置、设备和存储介质
CN113888578A (zh) * 2021-09-26 2022-01-04 合肥高维数据技术有限公司 自适应加权阈值技术的二值化方法
CN115661119A (zh) * 2022-11-11 2023-01-31 北京鉴智科技有限公司 一种连通域的检索方法、装置和一种连通域检索器

Also Published As

Publication number Publication date
CN109754379A (zh) 2019-05-14

Similar Documents

Publication Publication Date Title
WO2020135056A1 (zh) 一种图像处理方法及装置
CN111627009B (zh) 一种屏幕检测方法、装置及头戴显示设备
US11282185B2 (en) Information processing device, information processing method, and storage medium
WO2021051604A1 (zh) Osd的文字区域的识别方法、装置及存储介质
WO2023179122A1 (zh) 缺陷检测方法、装置、电子设备及可读存储介质
CN108875723B (zh) 对象检测方法、装置和系统及存储介质
WO2021051601A1 (zh) 利用Mask R-CNN选择检测框的方法及系统、电子装置及存储介质
CN111179243A (zh) 一种基于计算机视觉的小尺寸芯片裂纹检测方法及系统
US9311533B2 (en) Device and method for detecting the presence of a logo in a picture
WO2016127736A1 (zh) 指纹重叠区域面积的计算方法及电子装置
CN110619333B (zh) 一种文本行分割方法、文本行分割装置及电子设备
CN109214334B (zh) 车道线处理方法和装置
CN107622501B (zh) 一种医学图像的边界检测的方法
CN107016394B (zh) 一种交叉纤维特征点匹配方法
CN111460355B (zh) 一种页面解析方法和装置
CN111091571A (zh) 细胞核分割方法、装置、电子设备及计算机可读存储介质
CN115273115A (zh) 一种文档元素标注方法、装置、电子设备和存储介质
CN110570442A (zh) 一种复杂背景下轮廓检测方法、终端设备及存储介质
CN108229583B (zh) 一种基于主方向差分特征的快速模板匹配的方法及装置
WO2020051792A1 (zh) 指纹识别方法、装置、设备及存储介质
WO2020135230A1 (zh) 一种内切圆确定方法及装置
CN114677348A (zh) 一种基于视觉的ic芯片缺陷的检测方法、系统和存储介质
WO2018058573A1 (zh) 对象检测方法、对象检测装置以及电子设备
WO2024016686A1 (zh) 角点检测的方法和装置
CN111414912A (zh) 对接型焊缝特征点的识别方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19902596

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19902596

Country of ref document: EP

Kind code of ref document: A1