Image processing method, storage medium and electronic device
By dividing the image into multiple shards and performing strong edge point diffusion processing for each shard, the problems of large hardware resource overhead and complex control in the existing methods are solved, and resource conservation and processing simplification is achieved.
Patent Information
- Application Number
- CN202210508647.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-05-10
AI Technical Summary
The existing strong edge point diffusion method is large in hardware resource overhead and complex in control.
By dividing the target image into multiple slices, performing strong edge point diffusion processing, and determining whether it is necessary to reverse traversal and continue processing based on the processing results, the bandwidth requirement for the memory and processing complexity are reduced.
It realizes the saving of hardware resources during strong edge point diffusion processing, reduces the bandwidth usage of memory, and simplifies the control process.
Smart Images

Figure CN115035125B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular to an image processing method, a storage medium and an electronic device. Background Art
[0002] Edge detection is a basic problem in image processing and computer vision. Its purpose is to identify points in digital images where brightness changes significantly. In some edge detection algorithms, such as the Canny edge detection algorithm, the process of edge detection on an image includes the following steps: Gaussian smoothing of the input image to obtain the horizontal and vertical amplitudes; calculating the gradient amplitude and direction as the edge strength and direction at each pixel; performing non-maximum suppression on the gradient amplitude; performing double threshold processing and edge connection processing on the image to obtain edge information. In this algorithm, in the process of edge connection processing of the image, it is necessary to determine whether the current point is a weak edge point and whether there are strong edge points around it. If so, the current point needs to be changed to a strong edge point. Therefore, during the edge connection process, strong edge points may continue to diffuse, and the direction of diffusion of strong edge points is uncertain. Summary of the invention
[0003] The purpose of the present disclosure is to provide an image processing method, a storage medium and an electronic device, which are used to solve the problems of large hardware resource overhead and complex control in the existing strong edge point diffusion method.
[0004] The first aspect of the present disclosure provides an image processing method. The method includes: sequentially reading slices from a plurality of slices included in a target image from a first memory as target slices, performing strong edge point diffusion processing on the target slices to convert weak edge points in the target slices including strong edge points into strong edge points; writing the target slices with new enhanced edge points into the first memory, and determining whether there are slices to be processed that need to be processed again based on the target slices with new enhanced edge points; and if it is determined that there are slices to be processed, sequentially reading each of the slices to be processed from the first memory in the opposite direction of the last slice reading direction as the target slice, and performing the strong edge point diffusion processing on the target slice again.
[0005] In an embodiment of the first aspect, the method further includes: after performing the strong edge point diffusion processing on the target slice again, writing the target slice with new enhanced edge points into the first memory, and determining whether there is a slice that needs to perform the strong edge point diffusion processing again based on the target slice with new enhanced edge points.
[0006] In an embodiment of the first aspect, sequentially reading slices from a plurality of slices included in a target image from a first memory as target slices includes: reading the first slice of the target image in a first direction from the first memory as the target slice, and determining whether there is a slice to be processed that needs to be processed again based on the target slice with new enhanced edge points includes: judging whether its adjacent slice is a slice that needs to be processed again; if there is a next slice of the target slice in the first direction, reading the next slice of the target slice in the first direction from the first memory as the target slice, and repeating this step until there is no next slice of the target slice in the first direction.
[0007] In an embodiment of the first aspect, performing strong edge point diffusion processing on the target slice includes: writing the target slice into a second memory; reading each block of the target slice from the second memory in sequence as a target block, performing the strong edge point diffusion processing on the target block; and writing the target block with a new enhanced edge point into the second memory.
[0008] In an embodiment of the first aspect, determining whether there is a to-be-processed slice that needs to be processed again based on the target slice with a new enhanced edge point includes: judging whether an adjacent slice of the target slice is a slice that needs to be processed again based on the target block after the strong edge point diffusion process and whether the target slice needs to be traversed in reverse; if the target slice needs to be traversed in reverse, reading each block of the target slice from the second memory in sequence along the opposite direction of the last block reading direction as the target block for strong edge point diffusion process and writing the target block with the new enhanced edge point into the second memory, and judging whether an adjacent slice of the target slice is a slice that needs to be processed again based on the target block after the strong edge point diffusion process and whether the target slice needs to be traversed in reverse; and after the processing of each block of the target slice is completed, if there is a newly added strong edge point in the target slice, reading the target slice from the second memory and writing it into the first memory.
[0009] In an embodiment of the first aspect, reading each block of the target slice in sequence from the second memory as the target block and performing the strong edge point diffusion process on the target block includes: reading the first block of the target slice in the second direction from the second memory as the target block, and judging whether the adjacent slices of the target slice are slices that need to be processed with the strong edge point diffusion again and whether the target slice needs to be traversed in reverse based on the target block after the strong edge point diffusion process, including: if the next block of the target block exists in the second direction, reading the next block of the target block in the second direction from the second memory as the target block, and repeating this step until the next block of the target block does not exist in the second direction.
[0010] In an embodiment of the first aspect, performing the strong edge point diffusion processing on the target block includes: performing edge expansion processing on the left and right sides of the target block; and performing strong edge point diffusion processing on each pixel point in the target block, and repeating this step until there are no new strong edge points in the target block.
[0011] In an embodiment of the first aspect, for any pixel point in the target block, performing strong edge point diffusion processing on the pixel point includes: if the pixel point is a weak edge point and there is a strong edge point in the neighborhood of the pixel point, then configuring the pixel point as a strong edge point.
[0012] In an embodiment of the first aspect, there is at least one common row between adjacent slices in the target image, and judging whether the adjacent slices of the target slice are slices that need to be processed again and whether the target slice needs to be traversed in reverse according to the target block after the strong edge point diffusion process includes: judging whether there are new strong edge points in the common row between the target slice and its previous slice according to the target block after the strong edge point diffusion process, and if so, the previous slice of the target slice is the slice that needs to be processed again; and judging whether there are new strong edge points on the inverse boundary of the target block according to the target block after the strong edge point diffusion process, and if so, the target slice needs to be traversed in reverse.
[0013] In an embodiment of the first aspect, each of the slices has a first flag bit and a second flag bit, and the image processing method also includes: if the target slice needs to be traversed in reverse, the first flag bit of the target slice is configured to 1; and if the target slice is a slice that needs to be processed again, the second flag bit of the target slice is configured to 1.
[0014] A second aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the image processing method according to any one of the first aspects of the present disclosure.
[0015] The third aspect of the present disclosure provides an electronic device, comprising: a memory storing a computer program; and a processor communicatively connected to the memory and configured to call the computer program to execute the image processing method according to any one of the first aspects of the present disclosure.
[0016] As described above, according to the image processing method, storage medium and electronic device of one or more embodiments of the present disclosure, fewer hardware resources are required to implement strong edge point diffusion, which is beneficial to reducing the bandwidth of the memory and is relatively simple to implement. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Shown is an example diagram of a target image in an embodiment of the present disclosure.
[0018] Figure 2 Shown is a flowchart of an image processing method in an embodiment of the present disclosure.
[0019] Figure 3A Shown is a flow chart of key steps in an embodiment of the present disclosure.
[0020] Figure 3B Shown is an example diagram of a target shard in an embodiment of the present disclosure.
[0021] Figure 4 Shown is a flow chart of key steps in an embodiment of the present disclosure.
[0022] Figure 5 Shown is a flow chart of key steps in an embodiment of the present disclosure.
[0023] Figure 6 Shown is a flow chart of key steps in an embodiment of the present disclosure.
[0024] Figure 7 Shown is a schematic diagram of the structure of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] The following is an explanation of the embodiments of the present disclosure by specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0026] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure, and the illustrations only show the components related to the present disclosure rather than being drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout type may also be more complex. In addition, in this article, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0027] In the hardware implementation of some edge detection algorithms, edge connection processing usually requires converting weak edge points (represented by the value 2'd1) into strong edge points (represented by the value 2'd2) and saving the coordinates in RAM (Random Access Memory), and then storing the coordinates in DDR (Double Data Rate) memory. Since the horizontal and vertical coordinates of each point need to be represented by a bit width of 16 bits, the coordinates of each point need 32 bits. Taking a 1080P image as an example, the maximum bandwidth required is 1920×1080×32 bits. In addition, when the coordinates to be stored are relatively scattered, the entire control process becomes more complicated. In addition, DDR is in units of 128 bits or 256 bits, and a point corresponding to a coordinate has only 2 bits, so a large amount of redundant data will appear.
[0028] To address at least the above problems, an image processing method is provided according to an embodiment of the present disclosure. Hereinafter, specific implementations of the present disclosure will be described with reference to the accompanying drawings through exemplary embodiments.
[0029] In an embodiment of the present disclosure, the image processing method is used to perform strong edge point diffusion processing on a target image, wherein the target image is stored in a first memory. Figure 1 An example diagram of the target image described in the embodiment of the present disclosure is shown as follows: Figure 1 As shown, the target image includes a plurality of horizontal tiles, the width of each tile is preferably the same as the width of the target image, the height of each tile is M (M>3), and there is at least one common row between adjacent tiles. Figure 2 The flowchart of the image processing method described in the embodiment of the present disclosure is shown as follows: Figure 2 As shown, the image processing method in the embodiment of the present disclosure includes the following steps S11 and S12.
[0030] In step S11, slices among the multiple slices included in the target image are sequentially read from a first memory as target slices, and strong edge point diffusion processing is performed on the target slices to convert weak edge points in the target slices including strong edge points into strong edge points. The first memory is, for example, DDR.
[0031] In step S12, the target slice with new enhanced edge points is written into the first memory, and it is determined whether there is a slice to be processed that needs to be processed again by the strong edge point diffusion process based on the target slice with new enhanced edge points. It should be noted that in step S12, only the target slice with new enhanced edge points after the strong edge point diffusion process can be written back to the first memory, and the target slice without new enhanced edge points after the strong edge point diffusion process does not need to be written back to the first memory. This method can reduce the number of times the first memory is written back, which is beneficial to improving performance.
[0032] In step S13, if it is determined that the to-be-processed slices exist, the to-be-processed slices are sequentially read from the first memory in the opposite direction of the last slice reading direction as the target slices, and the target slices are subjected to the strong edge point diffusion process. For example, if the last slice reading process uses a top-to-bottom order to read the slices from the first memory for processing, then the current slice reading process uses a bottom-to-top order to read the slices from the first memory for processing, and the next slice reading process uses a top-to-bottom order to read the slices from the first memory for processing, and so on.
[0033] Optionally, the image processing method described in the embodiment of the present disclosure may further include: after performing the strong edge point diffusion processing on the target slice again, writing the target slice with new enhanced edge points into the first memory, and determining whether there is a slice that needs to perform the strong edge point diffusion processing again based on the target slice with new enhanced edge points.
[0034] Optionally, the image processing method in the embodiment of the present disclosure may further include the following steps: repeatedly executing the above step S13 until there are no more fragments to be processed.
[0035] Optionally, the image processing method described in the embodiment of the present disclosure may further include the following steps: if the to-be-processed slice does not exist, terminating the image processing method.
[0036] Optionally, before step S11, the image processing method described in the embodiment of the present disclosure may further include the following steps: expanding the target image to K pixel alignment, that is, expanding the width of the target image to an integer multiple of K pixel, where K is a positive integer, and its value is, for example, 64, and each pixel is 2 bits (2'd0 represents a non-edge point; 2'd1 represents a weak edge point; 2'd2 represents a strong edge point), and the part exceeding the target image can be expanded with 2'b0.
[0037] According to an embodiment of the present disclosure, sequentially reading slices from a plurality of slices included in a target image from a first memory as target slices includes: reading the first slice of the target image in a first direction from the first memory as the target slice, and the first direction may be, for example, from top to bottom or from bottom to top.
[0038] Determining whether there is a to-be-processed slice that needs to be processed again based on the target slice with the newly enhanced edge point includes: judging whether its adjacent slice is a slice that needs to be processed again; if there is a next slice of the target slice in the first direction, reading the next slice of the target slice in the first direction from the first memory as the target slice, and repeating this step until there is no next slice of the target slice in the first direction.
[0039] by Figure 1 Taking the target image shown as an example, when the first direction is from bottom to top, the first slice of the target image in the first direction is slice 0. In this embodiment, slice 0 is first read from the first memory as the target slice for strong edge point diffusion processing, and the processed slice 0 is used to determine whether its adjacent slices are slices that need to be processed again, and if there are weak edge points in slice 0 that are converted to strong edge points after the strong edge point diffusion processing is performed on slice 0, that is, there are new enhanced edge points, then the processed slice 0 is written back to the first memory. At this time, the next slice of slice 0 in the first direction is slice 1, so next, slice 1 is read from the first memory as the target slice for strong edge point diffusion processing, and the processed slice 1 is used to determine whether its adjacent slices are slices that need to be processed again, and if there are new enhanced edge points in slice 1 after the strong edge point diffusion processing is performed on slice 1, then the processed slice 1 is written back to the first memory, and so on, until slice N is processed and written back to the first memory.
[0040] Figure 3A The flowchart of the strong edge point diffusion process for the target slice in the embodiment of the present disclosure is shown. Figure 3AAs shown, in the embodiment of the present disclosure, the strong edge point diffusion processing on the target slice includes the following steps S31 to S33.
[0041] In step S31, the target slice is written into a second memory, where the second memory is, for example, a row buffer.
[0042] In step S32, each block of the target slice is sequentially read from the second memory as a target block, and the target block is subjected to the strong edge point diffusion process. Specifically, in step S32, each block of the target slice can be sequentially read as a target block for processing. Figure 3B An example diagram showing L blocks contained in a slice in an embodiment of the present disclosure is shown, where L is a positive integer and the size of each block is, for example, M×K.
[0043] In step S33, the target block with the new enhanced edge point is written into the second memory. It should be noted that in step S33, only the target block with the new enhanced edge point after the strong edge point diffusion process can be written back into the second memory, and the target block without the new enhanced edge point after the strong edge point diffusion process does not need to be written back into the second memory. This method can reduce the number of times the second memory is written back, which is conducive to improving performance.
[0044] Preferably, in step S33, each of the target blocks is written back to its original storage location in the second memory. For example, if the address range of the storage space occupied by a target block A in the second memory is a1-a2, then in step S33, the target block A is written back to the storage space in the second memory with the address range of a1-a2.
[0045] Optionally, Figure 4 1 is a flow chart showing the determination of whether there is a to-be-processed slice that needs to be processed again according to the target slice with a new enhanced edge point according to an embodiment of the present disclosure. Figure 4 As shown, in the embodiment of the present disclosure, determining whether there is a to-be-processed slice that needs to be processed again with the strong edge point diffusion process according to the target slice with the new enhanced edge point includes the following steps S41 to S43.
[0046] In step S41, it is determined based on the target block after the strong edge point diffusion process whether an adjacent slice of the target slice is a slice that needs to be subjected to the strong edge point diffusion process again and whether the target slice needs to be traversed in reverse.
[0047] In step S42, if the target slice needs to be traversed in reverse, the blocks of the target slice are read from the second memory in sequence along the opposite direction of the last block reading direction as the target block for strong edge point diffusion processing and the target block with new enhanced edge points is written into the second memory, and based on the target block after the strong edge point diffusion processing, it is determined whether the adjacent slices of the target slice are slices that need to be processed with the strong edge point diffusion again and whether the target slice needs to be traversed in reverse.
[0048] In step S43, after the processing of each block of the target slice is completed, if there is a newly added strong edge point in the target slice, the target slice is read from the second memory and written into the first memory.
[0049] Optionally, the image processing method of this embodiment may further include: repeatedly executing the above step S42 until the target slice does not need to be traversed in reverse, at which time, each of the blocks in the target slice has completed the strong edge point diffusion processing.
[0050] Preferably, in step S43, each of the target slices is written back to its original storage location in the first memory. For example, if the address range of the storage space occupied by a target slice B in the first memory is b1-b2, after being processed in steps S31b and S32b, in step S43, the target slice B is written back to the storage space in the first memory with the address range of b1-b2.
[0051] Optionally, reading each block of the target slice in sequence from the second memory as the target block and performing the strong edge point diffusion process on the target block includes: reading the first block of the target slice in the second direction from the second memory as the target block, and the second direction is, for example, from left to right or from right to left.
[0052] Judging, based on the target block after the strong edge point diffusion processing, whether an adjacent block of the target block is a block that needs to be processed with the strong edge point diffusion again and whether the target block needs to be traversed in reverse includes: if the next block of the target block exists in the second direction, reading the next block of the target block in the second direction from the second memory as the target block, and repeating this step until the next block of the target block does not exist in the second direction.
[0053] by Figure 3BTaking the target slice shown as an example, when the second direction is from left to right, the first block of the target slice in the second direction is block 0. In this embodiment, firstly, block 0 is read from the second memory as the target block for strong edge point diffusion processing, and it is judged whether the adjacent slices of the target slice are slices that need to be processed again and whether the target slice needs to be traversed in reverse according to the processed block 0. If there are new enhanced edge points in block 0 after the strong edge point diffusion processing, the processed block 0 is written back to the second memory. At this time, the next block of block 0 in the second direction is block 1, so next, block 1 is read from the second memory as the target block for strong edge point diffusion processing, and it is judged whether the adjacent slices of the target slice are slices that need to be processed again and whether the target slice needs to be traversed in reverse according to the processed block 1. If there are new enhanced edge points in block 1 after the strong edge point diffusion processing, the processed block 1 is written back to the second memory, and so on, until block L is processed and written back to the second memory.
[0054] Figure 5 The flowchart of the strong edge point diffusion process for the target block in the embodiment of the present disclosure is shown. Figure 5 As shown, the process of performing the strong edge point diffusion processing on the target block in the embodiment of the present disclosure includes the following steps S51 and S52.
[0055] In step S51, the left and right sides of the target block are expanded. The expansion process refers to splicing a column of pixels located on the left and right sides of the target block in the target slice to the left and right sides of the target block respectively. In particular, if there is no other block on one side of the target block, the side is expanded with 2'b0. Figure 3B Taking the target slice shown as an example, when expanding block 0, the leftmost column of pixels in block 1 is spliced to the right side of block 0, and a column of pixels with a pixel value of 2'b0 is added to the left side of block 0; when expanding block 1, the rightmost column of pixels in block 0 is spliced to the left side of block 1, and the leftmost column of pixels in block 2 is spliced to the right side of block 1, and so on.
[0056] In step S52, strong edge point diffusion is performed on each pixel point in the target block, and this step is repeated until no new strong edge points exist in the target block. Specifically, step S52 includes at least one round of strong edge point diffusion, for example, in a first round of strong edge point diffusion, each pixel point in the target block can be independently diffused, a second round of strong edge point diffusion is performed based on the result of the first round of strong edge point diffusion, a third round of strong edge point diffusion is performed based on the result of the second round of strong edge point diffusion, and so on, until no new strong edge points appear in a certain round of strong edge point diffusion.
[0057] It should be noted that in step S52 , only the pixel points in the target block may be subjected to strong edge point diffusion processing, and there is no need to perform strong edge point diffusion processing on the two columns of pixel points added in the edge expansion process.
[0058] Optionally, for any pixel point C in the target block, performing strong edge point diffusion processing on the pixel point C includes: if the pixel point C is a weak edge point and there is a strong edge point in the neighborhood of the pixel point, then configuring the pixel point as a strong edge point; otherwise, keeping the pixel point C as a weak edge point.
[0059] Optionally, the neighborhood of the pixel point C may be a 4-neighborhood, in which case the neighborhood of the pixel point C includes an upper pixel point, a lower pixel point, a left pixel point, and a right pixel point.
[0060] Optionally, the neighborhood of the pixel point C can be an 8-neighborhood, in which case the neighborhood of the pixel point C includes its upper left pixel, upper pixel, upper right pixel, left pixel, right pixel, lower left pixel, lower pixel and lower right pixel.
[0061] In one embodiment of the present disclosure, there is at least one common row between adjacent slices in the target image. Figure 6 The flowchart of the embodiment of the present disclosure shows that according to the target block after the strong edge point diffusion process, it is determined whether the adjacent slices of the target slice are slices that need to be processed with the strong edge point diffusion process again and whether the target slice needs to be traversed in reverse. Figure 6 As shown, in the embodiment of the present disclosure, judging whether the adjacent slices of the target slice are slices that need to be subjected to the strong edge point diffusion processing again and whether the target slice needs to be traversed in reverse according to the target block after the strong edge point diffusion processing includes the following steps S61 and S62.
[0062] In step S61, it is determined whether there are newly added strong edge points in the common row between the target slice and its previous slice according to the target slice after the strong edge point diffusion process. If there are, the previous slice of the target slice is the slice that needs to be processed again. It should be noted that when the first direction is from bottom to top, the previous slice of the target slice refers to the slice below the target slice, and when the first direction is from top to bottom, the previous slice of the target slice refers to the slice above the target slice.
[0063] In step S62, it is determined whether there are newly added strong edge points on the inverse boundary of the target block according to the target block after the strong edge point diffusion process. If there are, the target block needs to be traversed in reverse. The inverse boundary refers to the boundary between the target block and its previous block. For example, if the reading direction of the block is from right to left in a certain cycle, the inverse boundary of the block is the rightmost column of pixels of the block; if the reading direction of the block is from left to right in a certain cycle, the inverse boundary of the block is the leftmost column of pixels of the block.
[0064] Optionally, according to an embodiment of the present disclosure, each of the slices has a first flag bit, and the image processing method may further include: if the target slice needs to be traversed in reverse, the first flag bit of the target slice is configured to 1, otherwise, the first flag bit of the target slice is configured to 0.
[0065] Optionally, according to an embodiment of the present disclosure, each of the slices has a second flag bit, and the image processing method may further include: if the target slice is a slice that needs to be processed again, the second flag bit of the target slice is configured to 1, otherwise, the second flag bit of the target slice is configured to 0.
[0066] Optionally, according to an embodiment of the present disclosure, the image processing method may further include: using a third flag bit to indicate a traversal direction. For example, when the third flag bit is 1, the slices may be read from the first memory in a bottom-to-top order, and the blocks may be read from the second memory in a right-to-left order. When the third flag bit is 0, the slices may be read from the second memory in a top-to-bottom order, and the blocks may be read from the second memory in a left-to-right order.
[0067] According to another aspect of the present disclosure, a computer-readable storage medium is further provided, on which a computer program is stored. The computer program is executed by a processor to implement the image processing method described in the embodiment of the present disclosure.
[0068] According to another aspect of the present disclosure, an electronic device is also provided. Figure 7 is a block diagram showing an electronic device 700 according to an embodiment of the present disclosure. Figure 7 As shown, the electronic device 700 includes a memory 710 and a processor 720. The memory 710 is configured to store a computer program, and the processor 720 is communicatively connected to the memory 710 and configured to call the computer program to execute the image processing method described in the embodiment of the present disclosure.
[0069] Optionally, the electronic device 700 may further include a display 730. The display 730 is communicatively connected with the memory 710 and the processor 720, and is used to display a GUI interaction interface related to the image processing method described in the embodiment of the present disclosure.
[0070] The protection scope of the image processing method described in the present disclosure is not limited to the execution order of the steps listed in this embodiment, and all solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present disclosure are included in the protection scope of the present disclosure.
[0071] In summary, the image processing method described in the embodiment of the present disclosure requires less hardware resources when implementing strong edge point diffusion, which is beneficial to reducing the bandwidth of the memory and is relatively simple to implement. Therefore, the present disclosure effectively overcomes various shortcomings in the prior art and has high industrial utilization value.
[0072] The above embodiments are merely illustrative of the principles and effects of the present disclosure, and are not intended to limit the present disclosure. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present disclosure. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present disclosure shall still be covered by the claims of the present disclosure.
Claims
1. An image processing method, characterized in that: include: sequentially reading from the first memory slices from a plurality of slices included in the target image as target slices, wherein some of the target slices include strong edge points and weak edge points; Performing a strong edge point diffusion process on the target slice to convert weak edge points in the target slice including strong edge points into strong edge points; Writing the target slice with the new enhanced edge point into the first memory, and determining whether there is a slice to be processed that needs to be processed again with the strong edge point diffusion process according to the target slice with the new enhanced edge point; as well as If it is determined that the to-be-processed slices exist, the to-be-processed slices are read in sequence from the first memory in the opposite direction of the last slice reading direction as the target slices, and the strong edge point diffusion process is performed on the target slices.
2. The image processing method according to claim 1, characterized in that: Also includes: After performing the strong edge point diffusion process on the target slice again, the target slice with new enhanced edge points is written into the first memory, and it is determined whether there is a slice that needs to be subjected to the strong edge point diffusion process again according to the target slice with new enhanced edge points.
3. The image processing method according to claim 1, characterized in that: Reading slices from a plurality of slices included in a target image in sequence from a first memory as target slices includes: reading the first slice of the target image in a first direction from the first memory as the target slice, and determining whether there is a slice to be processed that needs to be processed again based on the target slice with new enhanced edge points includes: judging whether its adjacent slice is a slice that needs to be processed again; if the next slice of the target slice exists in the first direction, reading the next slice of the target slice in the first direction from the first memory as the target slice, and repeating this step until the next slice of the target slice does not exist in the first direction.
4. The image processing method according to claim 1, characterized in that: Performing strong edge point diffusion processing on the target slice includes: Writing the target slice into a second memory; sequentially reading each block of the target slice from the second memory as a target block, and performing the strong edge point diffusion process on the target block; and The target block having the new enhanced edge point is written into the second memory.
5. The image processing method according to claim 4, characterized in that: Determining whether there is a to-be-processed slice that needs to be processed again by the strong edge point diffusion process according to the target slice with the new enhanced edge point comprises: According to the target block after the strong edge point diffusion process, it is determined whether the adjacent slices of the target slice are slices that need to be processed by the strong edge point diffusion process again and whether the target slice needs to be traversed in reverse; If the target slice needs to be traversed in reverse, each block of the target slice is read from the second memory in sequence along the direction opposite to the direction of the last block reading as the target block for strong edge point diffusion processing and the target block with new enhanced edge points is written into the second memory, and according to the target block after the strong edge point diffusion processing, it is determined whether the adjacent slice of the target slice is a slice that needs to be processed with the strong edge point diffusion again and whether the target slice needs to be traversed in reverse; and After the processing of each block of the target slice is completed, if there is a newly added strong edge point in the target slice, the target slice is read from the second memory and written into the first memory.
6. The image processing method according to claim 5, characterized in that: Sequentially reading each block of the target slice from the second memory as the target block, and performing the strong edge point diffusion process on the target block comprises: reading the first block of the target slice in the second direction from the second memory as the target block, and Judging, based on the target block after the strong edge point diffusion processing, whether an adjacent block of the target block is a block that needs to be processed with the strong edge point diffusion again and whether the target block needs to be traversed in reverse includes: if the next block of the target block exists in the second direction, reading the next block of the target block in the second direction from the second memory as the target block, and repeating this step until the next block of the target block does not exist in the second direction.
7. The image processing method according to claim 4, characterized in that: Performing the strong edge point diffusion processing on the target block includes: Performing edge expansion processing on the left and right sides of the target block; and Perform strong edge point diffusion processing on each pixel point in the target block, and repeat this step until there is no newly added strong edge point in the target block.
8. The image processing method according to claim 7, characterized in that: For any pixel point in the target block, performing strong edge point diffusion processing on the pixel point includes: If the pixel is a weak edge point and there is a strong edge point in the neighborhood of the pixel, the pixel is configured as a strong edge point.
9. The image processing method according to claim 5, characterized in that: There is at least one common row between adjacent slices in the target image, and judging whether adjacent slices of the target slice are slices that need to be processed with the strong edge point diffusion again and whether the target slice needs to be traversed in reverse according to the target block after the strong edge point diffusion processing is performed includes: Determine whether there is a newly added strong edge point in the common row between the target slice and its previous slice according to the target slice after the strong edge point diffusion process, and if so, the previous slice of the target slice is the slice that needs to be processed again; and It is determined whether there are any newly added strong edge points on the inverse boundary of the target block according to the target block after the strong edge point diffusion process. If there are any newly added strong edge points, the target block needs to be traversed in reverse direction.
10. The image processing method according to claim 5, characterized in that: Each of the slices has a first flag bit and a second flag bit, and the image processing method further includes: If the target slice needs to be traversed in reverse, the first flag bit of the target slice is configured to be 1; and If the target slice is a slice that needs to be processed again, the second flag bit of the target slice is configured to be 1.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the image processing method according to any one of claims 1 to 10.
12. An electronic device, characterized in that: The electronic device comprises: a memory configured to store a computer program; and A processor is communicatively connected to the memory and configured to call the computer program to execute the image processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
PCB mark point edge reflection image detection method based on FACANNY algorithm
CN112132799A
Image zooming method and device, computer readable storage medium and terminal equipment
CN114418844A