Image downsampling method and device, electronic device and storage medium
By identifying the boundary type of pixel data groups and selecting the corresponding edge expansion mode and weight value, the problems of hardware timing adjustment and area increase in the prior art are solved, and efficient multi-level image downsampling is achieved.
Patent Information
- Application Number
- CN202310025374.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2043-01-09
AI Technical Summary
Existing horizontal three-means downsampling algorithms in image processing require timing adjustments and increased hardware area during hardware implementation, especially with significant overhead in multi-level downsampling.
By identifying whether a pixel data group contains data boundaries, the corresponding expansion mode and weight value are selected for mean calculation, avoiding data delay and timing adjustment, and achieving multi-level downsampling without increasing hardware area.
It reduces the difficulty of edge expansion processing, saves the delay waiting time in the downsampling process, and can achieve multi-level downsampling without increasing the hardware area.
Smart Images

Figure CN116055736B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to an image downsampling method and device, an electronic device and a storage medium. BACKGROUND
[0002] In image processing, there is a horizontal three-mean downsampling algorithm, as shown in the following formula (1), down_scale_mode represents the mode of obtaining downsampling. down_scale_mode=0 represents obtaining pixels according to even columns, and down_scale_mode=1 represents obtaining pixels according to odd columns. Assuming that an input image has 12 columns, as long as even columns or odd columns are selected, the color blocks marked with shadows in the image are the pixels that need to be left in the image, and the white color blocks that are not marked are the pixels that are discarded in the downsampling process. The shadow pixels left in the downsampling algorithm need to be output after mean processing with the left and right pixels. Figure 1
[0003] The horizontal three-mean downsampling algorithm is used in image processing to obtain a smaller size image. This algorithm selects even columns or odd columns of pixels according to rows to leave for three-mean (i.e., left pixel, middle pixel and right pixel) calculation. When even columns are selected to leave, the first three-mean calculation of each row lacks a left pixel and needs to be processed by left padding. When odd columns are selected to leave, the last three-mean calculation of each row lacks a right pixel and needs to be processed by right padding. If the downsampling algorithm needs to support the above two sampling modes when implemented in hardware, the left and right boundary copying padding needs to be considered, and the output timing of the two is different. Since the data in the current ISP (Image Signal Processor) is raster input, that is, it is processed pixel by pixel from left to right and from top to bottom, this processing of adding one pixel on the left and right sides will inevitably need to adjust the timing, bringing difficulties in padding. Moreover, sometimes in order to obtain different scale image information, multi-level downsampling needs to be performed on an image.
[0004] The current method for handling left and right boundary padding is to use data delay to complete the missing pixels. This method will increase the pipeline by 1 cycle (one clock unit) of time overhead. Moreover, the timing of left and right boundary processing is different, and additional control overhead needs to be added. When the image needs to be multi-level downsampling, using the existing method will greatly increase the hardware area. SUMMARY
[0005] The present application provides a multi-level image downsampling method and device, an electronic device and a storage medium, which can realize multi-level downsampling of an image without increasing the hardware area.
[0006] In one aspect of the present application, a method for image down-sampling is provided. The method comprises: obtaining pixel data groups in an image one by one according to a preset sampling mode; if the pixel data group includes a data boundary, selecting a corresponding edge extension mode according to the type of the data boundary; and obtaining a preset edge extension weight value in the edge extension mode to perform mean value calculation on the pixel data group according to the edge extension weight value to obtain edge extension mean value data.
[0007] In some embodiments, the method further comprises: performing image compression according to the edge extension mean value data.
[0008] In some embodiments, each pixel data group includes a preset number of pixel data, and the obtaining of the pixel data groups in the image one by one according to the preset sampling mode comprises: obtaining pixel data in the image one by one according to the preset sampling mode; if the pixel data is starting pixel data, storing the pixel data in a first pixel address; if the pixel data is intermediate pixel data, storing the pixel data in a second pixel address; and if the pixel data is terminal pixel data, determining whether the pixel data group includes a data boundary.
[0009] In some embodiments, the selecting of the corresponding edge extension mode according to the type of the data boundary comprises: if the type of the data boundary is a starting boundary, selecting a starting edge extension mode; and if the type of the data boundary is a terminal boundary, selecting a terminal edge extension mode.
[0010] In some embodiments, the edge extension weight value includes a boundary weight value, and the boundary weight values of the starting edge extension mode and the terminal edge extension mode are both zero.
[0011] In some embodiments, the method further comprises: if the pixel data group does not include a data boundary, selecting a non-edge extension mode; obtaining a preset non-edge extension weight value in the non-edge extension mode to perform mean value calculation on the pixel data group according to the non-edge extension weight value to obtain non-edge extension mean value data; and performing image compression according to the non-edge extension mean value data.
[0012] In another aspect of the present application, an image down-sampling device is provided. The device comprises: an obtaining module configured to obtain pixel data groups in an image one by one according to a preset sampling mode; a processing module configured to, if the pixel data group includes a data boundary, select a corresponding edge extension mode according to the type of the data boundary; and a calculation module configured to obtain a preset edge extension weight value in the edge extension mode to perform mean value calculation on the pixel data group according to the edge extension weight value to obtain edge extension mean value data.
[0013] In some embodiments, the calculation module is further configured to perform image compression according to the edge extension mean value data. In some embodiments, each pixel data group includes a preset number of pixel data, and the obtaining of the pixel data groups in the image one by one according to the preset sampling mode comprises: obtaining pixel data in the image one by one according to the preset sampling mode; if the pixel data is starting pixel data, storing the pixel data in a first pixel address; if the pixel data is intermediate pixel data, storing the pixel data in a second pixel address; and if the pixel data is terminal pixel data, determining whether the pixel data group includes a data boundary.
[0009] In some embodiments, the selecting of the corresponding edge extension mode according to the type of the data boundary comprises: if the type of the data boundary is a starting boundary, selecting a starting edge extension mode; and if the type of the data boundary is a terminal boundary, selecting a terminal edge extension mode.
[0010] In some embodiments, the edge extension weight value includes a boundary weight value, and the boundary weight values of the starting edge extension mode and the terminal edge extension mode are both zero.
[0011] In some embodiments, the method further comprises: if the pixel data group does not include a data boundary, selecting a non-edge extension mode; obtaining a preset non-edge extension weight value in the non-edge extension mode to perform mean value calculation on the pixel data group according to the non-edge extension weight value to obtain non-edge extension mean value data; and performing image compression according to the non-edge extension mean value data.
[0012] In another aspect of the present application, an image down-sampling device is provided. The device comprises: an obtaining module configured to obtain pixel data groups in an image one by one according to a preset sampling mode; a processing module configured to, if the pixel data group includes a data boundary, select a corresponding edge extension mode according to the type of the data boundary; and a calculation module configured to obtain a preset edge extension weight value in the edge extension mode to perform mean value calculation on the pixel data group according to the edge extension weight value to obtain edge extension mean value data.
[0013] In some embodiments, the calculation module is further configured to perform image compression according to the edge extension mean value data.
[0014] In some embodiments, each group of pixel data includes a preset number of pixel data, wherein the obtaining module includes: a sampling module configured to obtain pixel data in the image one by one according to a preset sampling mode; and a storage module configured to store the pixel data in a first pixel address if the pixel data is start pixel data, store the pixel data in a second pixel address if the pixel data is intermediate pixel data, and cause the processing module to determine whether the group of pixel data includes a data boundary if the pixel data is end pixel data.
[0015] In some embodiments, the processing module includes: an edge extension processing module configured to select a start edge extension mode if the type of the data boundary is a start boundary, and select an end edge extension mode if the type of the data boundary is an end boundary.
[0016] In some embodiments, the edge extension weight value includes a boundary weight value, and the boundary weight value of the start edge extension mode and the end edge extension mode is zero.
[0017] In some embodiments, the processing module further includes: a non-edge extension processing module configured to select a non-edge extension mode if the group of pixel data does not include a data boundary, wherein the calculation module is further configured to: obtain a preset non-edge extension weight value in the non-edge extension mode, perform mean value calculation on the group of pixel data according to the non-edge extension weight value to obtain non-edge extension mean value data, and perform image compression according to the non-edge extension mean value data.
[0018] In another aspect of the present application, an electronic device is provided. The electronic device includes a memory configured to store a computer program; and a processor configured to execute the computer program to perform the image down-sampling method described above.
[0019] In still another aspect of the present application, a computer readable medium is provided. The medium has a computer program stored thereon, and the computer program is executed by a processor to implement the image down-sampling method described above.
[0020] According to the embodiment of the present application, based on the current ISP raster input mode, taking each group of pixel data as a processing unit, whether the corresponding pixel data is missing in the group of pixel data is automatically identified by identifying whether the data boundary is contained in each group of pixel data. The group of pixel data missing the corresponding pixel data needs to be edge expansion processed, and in different types of data boundaries, the specific way of edge expansion processing is different. The down-sampling method in the embodiment of the present application takes the group of pixel data as a single processing unit, so it is not necessary to adjust the data output timing, and the difficulty of edge expansion processing is reduced. In addition, in different edge expansion processing methods, the corresponding weight value proportion is preset, after the type of data boundary is determined, the corresponding edge expansion weight value can be directly selected, thereby realizing dynamic adjustment of the three mean value calculation under different edge expansion processing. Compared with the prior art which processes the edge expansion problem by delay, the embodiment of the present application not only can save the frequent delay waiting time in the down-sampling process, and in the hardware implementation, the recyclable steps of the present application can realize the multi-module cascade, so as to realize the multi-level down-sampling of the image, and without increasing the hardware area. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 A schematic diagram of a horizontal direction three mean value down-sampling method in the prior art;
[0022] Figure 2 A flow chart of the image down-sampling method according to the embodiment of the present application;
[0023] Figure 3 A processing step flow chart of the group of pixel data not including the data boundary according to the embodiment of the present application;
[0024] Figure 4 A splitting step flow chart of the image down-sampling method according to the embodiment of the present application;
[0025] Figure 5 A module interface schematic diagram integrated by the image down-sampling method according to the embodiment of the present application;
[0026] Figure 6 A block diagram of the image down-sampling device according to the embodiment of the present application;
[0027] Figure 7 A schematic diagram of the electronic device according to the embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to explain the technical content, the achieved purposes and effects of the present application in detail, the following will be described in combination with the embodiments and the accompanying drawings.
[0029] In the prior art, the image downsampling algorithm handles the image boundary expansion problem by data delay to complete the missing pixels. This method increases a certain time overhead, and in hardware supporting two sampling modes, the timing of the data boundaries is different, and additional control overhead is required. When the image needs to be downsampled at multiple levels, using the existing method will greatly increase the hardware area.
[0030] To solve at least the above technical problems, the present disclosure provides an image downsampling method. According to the present disclosure, the pixel data groups are obtained one by one and it is judged whether the pixel data groups contain data boundaries, so that the corresponding expansion weight values are selected according to the type of the data boundaries to perform mean value calculation, and the expansion mean value data is obtained to perform image compression. In this way, according to the embodiments of the present disclosure, the pixel data groups that need to be expanded can be automatically identified, and the proportion of the expansion weight values of the pixel data groups is redistributed to solve the problem of mean value calculation distortion caused by the missing pixel data due to the existence of data boundaries; in addition, the embodiments of the present disclosure not only save the frequent delay waiting time in the downsampling process, but also can realize multi-module cascade in the hardware implementation, so as to realize multi-level downsampling of the image without increasing the hardware area.
[0031] Hereinafter, the technical solutions according to the present disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.
[0032] Figure 2 is a flowchart showing an image downsampling method 100 according to an embodiment of the present disclosure. Referring to Figure 2 , the method 100 includes the following steps 102 to 106.
[0033] In step 102, the pixel data groups in the image are obtained one by one according to the preset sampling mode. In some embodiments, each group of pixel data includes a preset number of pixel data, and obtaining the pixel data groups in the image one by one according to the preset sampling mode includes: obtaining the pixel data in the image one by one according to the preset sampling mode; if the pixel data is the starting pixel data, storing it in the first pixel address; if the pixel data is the intermediate pixel data, storing it in the second pixel address; and if the pixel data is the terminal pixel data, judging whether the pixel data group includes a data boundary. In this way, before each pixel data group is sampled, the pixel data except the terminal pixel data is stored in the corresponding data address respectively, the position type of the pixel data is distinguished by the preset data address, so that the pixel data and the weight value in the mean value calculation are one-to-one corresponding, and the weight value of each pixel data is dynamically adjusted. In addition, after the terminal pixel data is obtained, the next step is directly executed, so as to avoid the problem of one clock unit delay caused by repeated acquisition of the terminal pixel data when the pixel data group has missing pixel data.
[0034] At step 104, if the pixel data group includes a data boundary, a corresponding padding mode is selected according to the type of the data boundary. In some embodiments, if the type of the data boundary is a start boundary, a start padding mode is selected; and if the type of the data boundary is an end boundary, an end padding mode is selected. In this way, the pixel data located at the data boundary is screened, because the pixel data group located at the data boundary has a problem of missing pixel data, and the pixel at the image edge usually needs to be padded in the process of weighted average calculation, that is, the proportion of the weight value of each pixel data in the pixel data group is adjusted, so as to avoid the distortion of the average data caused by the missing of the pixel data; and the corresponding padding mode is selected through the type of the data boundary, so as to automatically identify the padding mode, and the difficulty of padding is reduced when the pixel data output timing is adjusted in hardware implementation.
[0035] At step 106, a preset padding weight value in the padding mode is obtained to perform average calculation on the pixel data group according to the padding weight value, so as to obtain padding average data. In some embodiments, the padding weight value includes a boundary weight value, and the boundary weight values of the start padding mode and the end padding mode are both zero. In this way, the weight value of the pixel data missing in the padding mode is set to zero, so as to represent that the pixel data belongs to the data boundary.
[0036] In some embodiments, the method 100 can further include performing image compression according to the padding average data.
[0037] According to the embodiments of the present disclosure, each group of pixel data is taken as a processing unit, whether the data boundary is included in each group of pixel data is identified, so as to automatically identify whether the corresponding pixel data is missing in the group of pixel data, and then different types of padding processing are performed on the group of pixel data. In addition, the pixel data group is taken as a single processing unit, and the data output timing does not need to be adjusted, so as to reduce the difficulty of padding processing. In addition, the corresponding weight value proportion is preset in different padding processing modes, and the corresponding padding weight value can be directly selected after the type of the data boundary is determined, so as to realize dynamic adjustment of the three average calculations under different padding processing. Therefore, the frequent delay waiting time in the down-sampling process is saved, and in hardware implementation, the cyclic steps can realize multi-module cascade, so as to realize multi-level down-sampling of the image, and the hardware area is not increased.
[0038] Figure 3 FIG. 1 is a flow chart illustrating the processing steps of the pixel data group not including the data boundary according to the embodiments of the present disclosure. Referring to FIG. 1, the method 100 can include the following steps 102, 104, 106, 108 and 110. Figure 3 Compared with the embodiments of FIG. 2, the method 100 can further include the following steps 108 and 110. Figure 2
[0039] At step 108, image compression is performed according to the extended mean value data obtained at step 106.
[0040] At step 110, if the pixel data group does not include data boundary, a non-extended mode is selected; a preset non-extended weight value in the non-extended mode is obtained to perform mean value calculation on the pixel data group according to the non-extended weight value to obtain non-extended mean value data; and image compression is performed according to the non-extended mean value data. In this way, when the pixel data does not contain data boundary, it means that there is no problem of pixel data loss in the pixel data group, and thus no extended processing is needed. Not only the automatic identification of the extended mode and the non-extended mode is realized, but also the distortion of mean value calculation caused by pixel loss is solved by re-distributing the weight value proportion of each pixel data. In addition, when a multi-level down-sampling is performed on an image, through the standardized sampling process, the missing pixels do not need to be completed by data delay in hardware implementation, avoiding additional time and control overhead, and without increasing hardware area.
[0041] Hereinafter, the application scenarios of the image down-sampling method and device according to the embodiments of the present application will be described by examples.
[0042] Figure 4 is a flow chart showing the splitting steps of an image down-sampling method according to an embodiment of the present application, including the following steps 202 to 220.
[0043] At step 202, each group of pixel data includes three pixel data, and the pixel data in the image is obtained one by one according to a preset sampling mode. The sampling mode includes the following in the horizontal direction: 1, selecting the even columns one by one to obtain the pixel data group; 2, selecting the odd columns one by one to obtain the pixel data group. Since the ISP raster input is a time sequence from left to right, when each group of pixel data is sampled, the starting pixel data is the pixel data on the left side of the even column or odd column pixel data, which is referred to as left pixel in this embodiment; the middle pixel data is the even column or odd column pixel data, which is referred to as middle pixel in this embodiment; and the terminal pixel data is the pixel data on the right side of the even column or odd column pixel data, which is referred to as right pixel in this embodiment.
[0044] At step 204, whether the pixel data group is sampled completely is determined by determining whether the right pixel data is obtained, if the right pixel data is not obtained, step 206 is performed; if the right pixel data is obtained, step 208 is performed.
[0045] At step 206, whether the pixel data is left pixel data is determined, if the pixel data is left pixel data, it is stored in the left pixel address, if the pixel data is not left pixel data, but middle pixel data, it is stored in the middle pixel address.
[0046] In step 208, if the pixel data is right pixel data, a right pixel address is referenced and step 210 is performed. Since each group of pixel data only includes three pixel data, the right pixel address is the terminal pixel address, and the right pixel data is obtained, indicating that the group of pixel data has been sampled. When sampling the pixel data group containing the right data boundary, there is a problem of missing right pixel data, so in this pixel data group, the middle pixel data is also the terminal (right) pixel data in the group of pixel data, so the right pixel address here can also refer to the middle pixel address.
[0047] In step 210, it is judged whether the pixel data group includes a column boundary. If it includes a column boundary, step 212 is performed, and if it does not include a column boundary, step 218 is performed. Before step 202, a pixel identifier of the column boundary is preset. If the type of the column boundary is a start boundary, the pixel identifier is set as a start identifier, and if the type of the column boundary is a terminal boundary, the pixel identifier is set as a terminal identifier. Whether the pixel data group includes a column boundary is determined by judging whether the pixel data group includes the pixel identifier.
[0048] In step 212, it is judged whether the type of the column boundary is a left extension boundary. If yes, a left extension boundary mode is selected and step 214 is performed, and if no, a right extension boundary mode is selected and step 216 is performed.
[0049] The weight value includes a left pixel weight value, a middle pixel weight value, and a right pixel weight value, and the sum of the weight values is 2n; the calculation formula of the average value calculation is iX+jY+kZ / (i+j+k), wherein i is the left pixel weight value, j is the middle pixel weight value, k is the right pixel weight value, X is the left pixel data, Y is the middle pixel data, and Z is the right pixel data.
[0050] In step 214, the left pixel weight value i=0, the middle pixel weight value j=11, and the right pixel weight value k=5 are used to perform average value calculation on the pixel data group, and the left extension boundary average value data is obtained.
[0051] In step 216, the pixel data group is calculated with the left pixel weight value i=5, the middle pixel weight value j=0, and the right pixel weight value k=11 to obtain the right edge expansion average data. When the pixel data group containing the right data boundary is sampled, the middle pixel data is also the right pixel data in the pixel data group, but the middle pixel data needs to be saved in the middle pixel address after sampling, which causes an invalid cycle (clock unit) to be wasted to obtain repeated pixel data when the pixel data is obtained. Therefore, the right pixel data is directly used as the middle pixel data in step 216, and thus the right pixel weight value k=11 is the sum of the middle pixel weight value and the right pixel weight value, so that the delay of one cycle (clock unit) is reduced.
[0052] In step 218, the pixel data group is calculated with the left pixel weight value i=5, the middle pixel weight value j=6, and the right pixel weight value k=5 to obtain the non-edge expansion average data.
[0053] In step 220, it is determined whether the N-level downsampling of the image is completed. If not, the non-edge expansion average data, the left edge expansion average data, and the right edge expansion average data are recombined into the pixel data of the image, and the step 202 is returned to be executed until the N-level downsampling of the image is completed and the average data is output; if yes, the average data is directly output.
[0054] Figure 5 FIG. 1 is a schematic diagram of a module interface integrated by the image downsampling method according to the embodiment of the present disclosure. Referring to FIG. 1, Figure 5 left_ratio is used to obtain the left pixel weight value, mid_ratio is used to obtain the middle pixel weight value, right_ratio is used to obtain the right pixel weight value, down_scale_mode is used to obtain the mode of downsampling, down_scale_mode is 0, sampling starts from the first pixel, that is, pixel data groups are obtained according to even columns one by one, down_scale_mode is 1, sampling starts from the second pixel, that is, pixel data groups are obtained according to odd columns one by one, in_valid is used to obtain the valid signal of input pixel data, in_data is used to obtain the pixel data, in_h_end is used to obtain the identification of the last pixel in the input row, in_v_end is used to obtain the identification of the last row of the input image, out_valid is used to output the valid signal of average data, out_data is used to output the average data, out_h_end is used to output the identification of the last pixel in the row, and out_v_end is used to output the identification of the last row of the image.
[0055] According to another aspect of the present disclosure,Figure 6 is a block diagram illustrating an image down-sampling apparatus 300 according to an embodiment of the present application. Referring to Figure 6 , the image down-sampling apparatus 300 comprises an obtaining module 302, a processing module 304 and a calculating module 306. The obtaining module 302 is configured to obtain pixel data groups in an image one by one according to a preset sampling mode. The processing module 304 is configured to select a corresponding edge extension mode according to a type of a data boundary if the pixel data groups comprise the data boundary. The calculating module 306 is configured to obtain a preset edge extension weight value in the edge extension mode, to perform mean value calculation on the pixel data groups according to the edge extension weight value, and to obtain edge extension mean value data.
[0056] In some embodiments, the calculating module 306 is further configured to perform image compression according to the edge extension mean value data.
[0057] In some embodiments, the obtaining module 302 comprises a sampling module 3022 and a storage module 3024. The sampling module 3022 is configured to obtain pixel data in an image one by one according to a preset sampling mode. The storage module 3024 is configured to store into a first pixel address if the pixel data is start pixel data, to store into a second pixel address if the pixel data is intermediate pixel data, and to make the processing module 304 judge whether the pixel data groups comprise a data boundary if the pixel data is end pixel data.
[0058] In some embodiments, the processing module 304 comprises an edge extension processing module 3042. The edge extension processing module 3042 is configured to select a start edge extension mode if the type of the data boundary is a start boundary, and to select an end edge extension mode if the type of the data boundary is an end boundary.
[0059] In some embodiments, the edge extension weight value comprises a boundary weight value, and the boundary weight values of the start edge extension mode and the end edge extension mode are both zero.
[0060] In some embodiments, the processing module 304 further comprises a non-edge extension processing module 3044. The non-edge extension processing module 3044 is configured to select a non-edge extension mode if the pixel data groups do not comprise a data boundary. The calculating module 306 is further configured to obtain a preset non-edge extension weight value in the non-edge extension mode, to perform mean value calculation on the pixel data groups according to the non-edge extension weight value, to obtain non-edge extension mean value data, and to perform image compression according to the non-edge extension mean value data.
[0061] According to yet another aspect of the present application, Figure 7 is a schematic diagram illustrating an electronic device 400 according to an embodiment of the present application. Referring toFigure 7 The electronic device 400 comprises a memory 402, a processor 404, and a computer program stored on the memory and executable on the processor, the processor implementing the steps or actions of the image downsampling method as described above when executing the computer program.
[0062] According to yet another aspect of the present application, a computer readable medium is provided. The computer readable medium has stored thereon a computer program which, when executed by a processor, implements the image downsampling method as described above.
[0063] In summary, the image downsampling method and device, electronic device and storage medium provided by the present application store the pixel data of the same group into the preset data address respectively to determine whether each group of pixel data is complete, so that the pixel data and the weight value are one-to-one corresponding, and the weight value proportion is adjusted dynamically according to the processing mode of the pixel data. In the prior art, the pixel data group located at the data boundary lacks pixel data when the mean value is calculated, and needs to be expanded, so the pixel data group is screened after each group of pixel data is sampled to determine whether the pixel data group contains the data boundary, so as to select the corresponding processing mode, realize the automatic identification of the expansion operation of the pixel data, and reduce the difficulty of expansion without adjusting the time sequence of the pixel data output when the hardware is implemented. In addition, the weight value corresponding to each pixel is different when the pixel data of the expansion and non-expansion processing is calculated, so the corresponding weight value is preset in each mode, so as to realize the weight value proportion of each pixel data, and solve the mean value calculation distortion problem caused by the pixel loss. Finally, when a plurality of levels of image downsampling are performed, the missing pixel is completed without data delay when the hardware is implemented through the standardized sampling process, the additional time and control overhead are avoided, and the hardware area does not need to be increased.
[0064] The above description is only an embodiment of the present application, and does not limit the patent scope of the present application, and any equivalent transformation or direct or indirect application in the related technical field based on the content of the specification and drawings of the present application is also included in the patent protection scope of the present application.
Claims
1. An image downsampling method, characterized in that, include: The pixel data groups in the image are acquired one by one according to the preset sampling mode; If the pixel data group includes a data boundary, then the corresponding edge expansion mode is selected according to the type of the data boundary; if the type of the data boundary is a starting boundary, then the starting edge expansion mode is selected; and Obtain the preset expansion weight value in the expansion mode, and calculate the mean value of the pixel data group based on the expansion weight value to obtain the expansion mean data. The edge expansion weight value includes the boundary weight value, and the boundary weight value of the initial edge expansion mode is zero.
2. The image downsampling method according to claim 1, characterized in that, Also includes: Image compression is performed based on the expanded edge mean data.
3. The image downsampling method according to claim 1, characterized in that, Each set of pixel data includes a preset number of pixel data, wherein the pixel data sets in the image are acquired one by one according to a preset sampling mode, including: Pixel data in the image is acquired one by one according to the preset sampling mode; If the pixel data is the starting pixel data, then it is stored in the first pixel address; If the pixel data is intermediate pixel data, then store it in the address of the second pixel; and If the pixel data is terminating pixel data, then determine whether the pixel data group includes a data boundary.
4. The image downsampling method according to claim 1, characterized in that, Selecting the corresponding expansion mode based on the type of the data boundary also includes: If the data boundary type is a termination boundary, then the termination expansion mode is selected.
5. The image downsampling method according to claim 4, characterized in that, The boundary weight value of the terminated edge expansion mode is zero.
6. The image downsampling method according to claim 1, characterized in that, Also includes: If the pixel data group does not include data boundaries, then the non-extended edge mode is selected; Obtain the preset non-expansion weight value in the non-expansion mode, and calculate the mean value of the pixel data group according to the non-expansion weight value to obtain the non-expansion mean data; as well as Image compression is performed based on the non-expanded mean data.
7. An image downsampling device, characterized in that, include: The acquisition module is configured to acquire pixel data groups in the image one by one according to a preset sampling mode; The processing module is configured to select a corresponding edge expansion mode based on the type of the data boundary if the pixel data group includes a data boundary. as well as The calculation module is configured to obtain a preset expansion weight value in the expansion mode, and to perform mean calculation on the pixel data group according to the expansion weight value to obtain the expanded mean data. The processing module includes an edge expansion processing module, which is configured to select an initial edge expansion mode if the data boundary type is an initial boundary. The edge expansion weight value includes the boundary weight value, and the boundary weight value of the initial edge expansion mode is zero.
8. The image downsampling device according to claim 7, characterized in that, The computing module is further configured as follows: Image compression is performed based on the expanded edge mean data.
9. The image downsampling device according to claim 7, characterized in that, Each set of pixel data includes a preset number of pixel data, wherein the acquisition module includes: The sampling module is configured to acquire pixel data from the image one by one according to a preset sampling mode; and The storage module is configured to store the pixel data at a first pixel address if the pixel data is starting pixel data; store the pixel data at a second pixel address if the pixel data is intermediate pixel data; and, if the pixel data is ending pixel data, to cause the processing module to determine whether the pixel data group includes a data boundary.
10. The image downsampling device according to claim 7, characterized in that, The edge expansion processing module is also configured to select the termination edge expansion mode if the data boundary type is a termination boundary.
11. The image downsampling device according to claim 10, characterized in that, The boundary weight values of the terminated edge expansion mode are all zero.
12. The image downsampling device according to claim 7, characterized in that, The processing module further includes: The non-edge expansion processing module is configured to select the non-edge expansion mode if the pixel data group does not include data boundaries. The computing module is further configured as follows: Obtain a preset non-expansion weight value in the non-expansion mode, and calculate the mean of the pixel data group based on the non-expansion weight value to obtain non-expansion mean data; and Image compression is performed based on the non-expanded mean data.
13. An electronic device, characterized in that, include: Memory, configured to store computer programs; as well as The processor is configured to execute the computer program to perform the image downsampling method according to any one of claims 1 to 6.
14. A computer-readable medium having a computer program stored thereon, characterized in that, The computer program is executed to implement the image downsampling method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Optical field image compression method based on macro pixel boundary matching
CN106961605A
Image defogging method and device
CN113362235A
Method for compressing and reconstructing a data representation of a picture
US4717962A