Image processing method and device and electronic equipment

By calculating and adjusting the coordinate deviation of the cropped area, the problem of point coordinate deviation in local enlarged images in image processing is solved, and the coordinate accuracy of the target point is improved.

CN120147340APending Publication Date: 2025-06-13HANGZHOU MICROIMAGE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510230746.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

During the image processing process, due to system data processing rules and other reasons, the coordinate information of the cropped area is deviated, resulting in the coordinate information of each point in the local enlarged image.

Method used

By calculating the deviation between the actual coordinate information and theoretical coordinate information of the cropped area, coordinate adjustment is performed to compensate for the cropping deviation and ensure that the position of the target point in the local enlarged image is accurate.

Benefits of technology

It effectively reduces the position deviation of points in the image and improves the coordinate accuracy of target points in the local enlarged image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120147340A_ABST
    Figure CN120147340A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, and particularly provides an image processing method and device and electronic equipment. The method comprises the following steps: determining a cutting deviation caused by cutting according to actual coordinate information of a cutting area obtained by cutting an image to be processed and theoretical coordinate information required by cutting; and based on the cutting deviation and the amplification factor corresponding to the cutting area, performing coordinate adjustment on the area zoom image obtained after amplification based on the cutting area so as to compensate the coordinate deviation of the target point caused by the cutting deviation. Thus, when the image is locally amplified, coordinate adjustment can be performed on the regional zoom image obtained after amplification, and the coordinate deviation of the target point can be further reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technologies, and in particular, to a method, an apparatus, and an electronic device for image processing. Background Art

[0002] In some image processing scenarios, it is usually necessary to locally magnify an image containing a specific point to obtain a locally magnified image, and perform corresponding operations based on the position of the point in the locally magnified image.

[0003] Under the related art, an image containing a target point (i.e., a specific point) is usually cropped to obtain a cropped area containing the target point, and the cropped area is magnified to obtain a locally magnified image.

[0004] However, due to reasons such as the data processing rules of the system (e.g., the coordinate values need to be integers), the coordinate information of the area cropped from the image usually has deviations, which in turn leads to deviations in the coordinate information of each point in the locally magnified image. Summary of the Invention

[0005] To solve the above technical problems, an object of the embodiments of the present disclosure is to provide a method, an apparatus, and an electronic device for image processing.

[0006] On the one hand, an embodiment of the present disclosure provides a method for image processing, including:

[0007] Determine a cropping deviation caused by cropping according to the actual coordinate information of a cropped area obtained by cropping a to-be-processed image and the theoretical coordinate information required for cropping; the theoretical coordinate information is calculated according to the coordinates of a target point in the to-be-processed image and the magnification ratio for magnifying the cropped area, so that the cropped area contains the target point;

[0008] Based on the cropping deviation and the magnification ratio corresponding to the cropped area, perform coordinate adjustment on the area magnification image obtained by magnifying the cropped area to compensate for the coordinate offset of the target point caused by the cropping deviation.

[0009] In an implementation manner, determining a cropping deviation caused by cropping according to the actual coordinate information of a cropped area obtained by cropping a to-be-processed image and the theoretical coordinate information required for cropping includes:

[0010] Calculate the theoretical coordinate information according to the first coordinates of the target point in the to-be-processed image and the magnification ratio corresponding to the cropped area;

[0011] Fine-tune the theoretical coordinate information according to the system data processing rules to obtain the actual coordinate information;

[0012] Crop the image to be processed according to the actual coordinate information to obtain a cropped area;

[0013] Obtain a cropping deviation based on the first coordinate and the second coordinate of the target point in the cropped area.

[0014] In one implementation, based on the cropping deviation and the magnification factor corresponding to the cropped area, perform coordinate adjustment on the area magnification image obtained by magnifying the cropped area, including:

[0015] In the case of performing first-level magnification on the image to be processed, magnify the cropped area according to the magnification factor corresponding to the cropped area to obtain an area magnification image;

[0016] Determine a magnification deviation according to the product of the magnification factor corresponding to the cropped area and the cropping deviation;

[0017] Perform translational compensation on the area magnification image according to the magnification deviation.

[0018] In one implementation, based on the cropping deviation and the magnification factor corresponding to the cropped area, perform coordinate adjustment on the area magnification image obtained by magnifying the cropped area, including:

[0019] In the case of performing multi-level magnification on the image to be processed, for the m-th level magnification in the multi-level magnification, perform the following steps:

[0020] Crop the area magnification image obtained during the (m - 1)-th level magnification to obtain a new cropped area and its corresponding cropping deviation; m is a positive integer greater than 1;

[0021] Magnify the new cropped area according to the magnification factor corresponding to the new cropped area to obtain a new area magnification image;

[0022] In the case where the m-th level is the last level in the multi-level magnification, perform translational compensation on the new area magnification image according to the cropping deviations and magnification factors corresponding to the cropped areas obtained during each level of magnification.

[0023] In one implementation, perform translational compensation on the new area magnification image according to the cropping deviations and magnification factors corresponding to the cropped areas obtained during each level of magnification, including:

[0024] For the m-th level magnification in the multi-level magnification, perform the following steps:

[0025] Obtain the magnification deviation at the m-th level of magnification according to the sum of the magnification deviation at the (m - 1)-th level of magnification and the cropping deviation at the m-th level of magnification, and the magnification factor corresponding to the cropped area obtained during the m-th level of magnification;

[0026] In the case where the m-th stage is the last stage of the multi-stage zoom, perform translational compensation on the region zoomed image obtained during the m-th stage zoom according to the zoom deviation during the m-th stage zoom.

[0027] On the one hand, an embodiment of the present disclosure provides an image processing apparatus, including:

[0028] A cropping unit, configured to determine a cropping deviation caused by cropping according to the actual coordinate information of the cropping region obtained by cropping the image to be processed and the theoretical coordinate information required for cropping; the theoretical coordinate information is calculated according to the coordinates of the target point in the image to be processed and the magnification factor for magnifying the cropping region, so that the cropping region cropped contains the target point;

[0029] An adjustment unit, configured to perform coordinate adjustment on the region zoomed image obtained after magnifying the cropping region based on the cropping deviation and the magnification factor corresponding to the cropping region, so as to compensate for the coordinate offset of the target point caused by the cropping deviation.

[0030] In one implementation, the cropping unit is configured to:

[0031] Calculate the theoretical coordinate information according to the first coordinate of the target point in the image to be processed and the magnification factor corresponding to the cropping region;

[0032] Fine-tune the theoretical coordinate information according to the system data processing rules to obtain the actual coordinate information;

[0033] Crop the image to be processed according to the actual coordinate information to obtain a cropping region;

[0034] Obtain the cropping deviation according to the first coordinate and the second coordinate of the target point in the cropping region.

[0035] In one implementation, the adjustment unit is configured to:

[0036] In the case of performing one-stage zoom on the image to be processed, magnify the cropping region according to the magnification factor corresponding to the cropping region to obtain a region zoomed image;

[0037] Determine the zoom deviation according to the product of the magnification factor corresponding to the cropping region and the cropping deviation;

[0038] Perform translational compensation on the region zoomed image according to the zoom deviation.

[0039] In one implementation, the adjustment unit is configured to:

[0040] In the case of performing multi-stage zoom on the image to be processed, for the m-th stage zoom in the multi-stage zoom, perform the following steps:

[0041] Crop the region-varied image during the (m - 1)-th stage of zooming to obtain a new cropped region and its corresponding cropping deviation; m is a positive integer greater than 1;

[0042] Enlarge the new cropped region according to the magnification factor corresponding to the new cropped region to obtain a new region-varied image;

[0043] In the case where the m-th stage is the last stage of multi-stage zooming, perform translational compensation on the new region-varied image according to the cropping deviation and magnification factor corresponding to the cropped region obtained during each stage of zooming.

[0044] In one implementation, the adjustment unit is configured to:

[0045] For the m-th stage of zooming in multi-stage zooming, perform the following steps:

[0046] Obtain the zooming deviation during the m-th stage of zooming according to the sum of the zooming deviation during the (m - 1)-th stage of zooming and the cropping deviation during the m-th stage of zooming, and the magnification factor corresponding to the cropped region obtained during the m-th stage of zooming;

[0047] In the case where the m-th stage is the last stage of multi-stage zooming, perform translational compensation on the region-varied image obtained during the m-th stage of zooming according to the zooming deviation during the m-th stage of zooming.

[0048] On the one hand, an electronic device is provided in an embodiment of the present disclosure, including:

[0049] A processor; and

[0050] A memory storing computer instructions, the computer instructions being configured to cause the processor to execute the steps of the methods provided in various optional implementations of any one of the above image processing.

[0051] On the one hand, a computer-readable storage medium is provided in an embodiment of the present disclosure, storing computer instructions, the computer instructions being configured to cause a computer to execute the steps of the methods provided in various optional implementations of any one of the above image processing.

[0052] On the one hand, a computer program product is provided in an embodiment of the present disclosure, including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the steps of the methods provided in various optional implementations of any one of the above image processing.

[0053] The method for image processing in the embodiments of the present disclosure includes determining a cropping deviation caused by cropping based on the actual coordinate information of a cropping area obtained by cropping an image to be processed and the theoretical coordinate information required for cropping; and performing coordinate adjustment on a region-varied image obtained by magnifying the cropping area based on the cropping deviation and the magnification factor corresponding to the cropping area, so as to compensate for the coordinate offset of a target point caused by the cropping deviation. In this way, when locally magnifying an image, coordinate adjustment can be performed on the region-varied image obtained after magnification, thereby reducing the coordinate deviation of the target point. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 is a flowchart of a method for image processing in the embodiments of the present disclosure.

[0055] Figure 2 is an example diagram of fixed-point magnification in the embodiments of the present disclosure.

[0056] Figure 3 is an example diagram of a cropping area in the embodiments of the present disclosure.

[0057] Figure 4 is an example diagram of multi-level magnification of an image in the embodiments of the present disclosure.

[0058] Figure 5 is an example diagram of a target-varied image in the embodiments of the present disclosure.

[0059] Figure 6 is a structural block diagram of an apparatus for image processing in the embodiments of the present disclosure. DETAILED DESCRIPTION

[0060] The technical solutions of the present disclosure will be described clearly and completely below with reference to the accompanying drawings. Apparently, the described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure. In addition, the technical features involved in different embodiments of the present disclosure described below can be combined with each other as long as they do not conflict with each other.

[0061] Some electronic devices usually display an indication icon (e.g., a firing table) for pointing to a target object on the screen. When locally magnifying an image, it is usually desired that the accuracy of the indication icon is as high as possible. Further, the center of the indication icon can be pointed to the same fixed target object in real time. In the related art, generally, based on the center of the indication icon, the acquired image is cropped and magnified to obtain a locally magnified image.

[0062] However, due to reasons such as the data processing rules of the system, the theoretical coordinate information required for the cropping area is usually fine-tuned (e.g., coordinate alignment or data rounding) to obtain the actual coordinate information of the cropping area. Then, subsequent processing is performed on the cropping area, which results in the same deviation between the actual coordinate information and the theoretical coordinate information of each point in the cropping area. As a result, after the image is enlarged, the coordinates of each point in the locally enlarged image have deviations, and obviously, the position of the center of the indication icon also has deviations.

[0063] Based on the defects existing in the above related technologies, in the embodiments of the present disclosure, a method, an apparatus, and an electronic device for image processing are provided, aiming to reduce the position deviation of points in the image when the image is locally enlarged.

[0064] In the embodiments of the present disclosure, a method for image processing is provided. This method can be applied to an electronic device. The present disclosure does not limit the type of the electronic device, which can be any device type suitable for implementation, such as a terminal device and a server, etc. The present disclosure will not elaborate on this.

[0065] Refer to Figure 1 As shown, it is a flowchart of a method for image processing in the embodiments of the present disclosure. The following will describe this method in conjunction with Figure 1 This method is described as follows. The specific implementation process of this method is as follows:

[0066] Step 101: Determine the cropping deviation caused by cropping based on the actual coordinate information of the cropping area obtained by cropping the image to be processed and the theoretical coordinate information required for cropping. The theoretical coordinate information is calculated based on the coordinates of the target point in the image to be processed and the magnification ratio for enlarging the cropping area, so that the cropping area cropped contains the target point.

[0067] In one implementation, when performing step 101, the following steps can be adopted:

[0068] S1011: Obtain the first coordinate of the target point in the image to be processed.

[0069] Optionally, the target point can be any point in the image to be processed, which can be selected by the user, can also be pre-configured, or can also be determined by object recognition and other means.

[0070] In one application scenario, image acquisition is performed on the target tracking object to obtain the image to be processed containing the target tracking object, and the image to be processed is recognized to obtain the recognized target tracking object, and the center position of the target tracking object is used as the target point. For example, the first coordinate of the target point is (5, 5).

[0071] S1012: Calculate the theoretical coordinate information based on the first coordinate of the target point in the image to be processed and the magnification factor corresponding to the cropping area.

[0072] For ease of description below, the area corresponding to the theoretical coordinate information can be referred to as the theoretical cropping area, and the area corresponding to the actual coordinate information can be referred to as the actual cropping area.

[0073] Among them, the target point is included before and after the adjustment of the cropping area. The target point is used to determine the theoretical coordinate information. The size of the theoretical cropping area is positively correlated with the size of the image to be processed and negatively correlated with the magnification factor. That is to say, based on the target point, the theoretical area range of the cropping area is selected. The size of the theoretical cropping area is: the ratio of the size of the image to be processed to the magnification factor.

[0074] In one implementation, the cropping can be performed in a way of fixed-point zooming, that is, based on the target point and the size of the theoretical cropping area, determine the area position of the theoretical cropping area, so that the coordinates of the target point in the image to be processed and the theoretical cropping area are the same, and the relative position of the target point in the images before and after zooming remains unchanged.

[0075] As an example, for each boundary (i.e., the border) of the image to be processed, determine the image boundary distance between the target point and the boundary, and obtain the area boundary distance between the target point and the boundary of the theoretical cropping area according to the ratio of the image boundary distance to the magnification factor. And for each area boundary distance, determine the position of the corresponding area boundary according to the target point and the area boundary distance, so as to obtain the theoretical coordinate information.

[0076] Among them, the relative position of the target point before and after the image zooming remains unchanged, which means that without considering the deviation, the positional relationship between the target point and the center points of the images before and after magnification remains unchanged. The target point can also be called the zoom center. The so-called fixed-point zooming means that during the image magnification process, the coordinates of the same target point do not change relative to the coordinate system of the original image. This means that no matter how the image is magnified, the position of the target point in the image is fixed, only its displayed size will change.

[0077] For example, refer to Figure 2 shown in the figure, which is an example diagram of fixed-point zooming. Figure 2 In the figure, the fixed-point zooming method is adopted to crop the image to be processed based on the target point to obtain the cropping area, and the cropping area is magnified to obtain the magnified image. Without considering the cropping deviation, the relative position of the target point in the image to be processed and the relative position in the magnified image remain unchanged.

[0078] In another implementation, the target point can also be the center point of the theoretical cropping area, so that based on this center point, theoretical coordinate information, such as vertex positions, can be calculated.

[0079] As an example, according to the ratio of the image to be processed to the magnification factor, the size of the theoretical cropping area is obtained, and based on the size and the center point of the theoretical cropping area, the theoretical coordinate information is determined.

[0080] Furthermore, based on the target point, reference points for the cropping area can be selected from the image to be processed, and the cropping area can be located based on the reference points for subsequent cropping.

[0081] Among them, the distance between the reference point and the target point is lower than the set cropping distance threshold.

[0082] In practical applications, the set cropping distance threshold (e.g., 10 pixels) can be set according to the actual application scenario and is not limited here.

[0083] In this way, cropping can also be performed based on the points adjacent to the target point, so that the target point is still included after the image is cropped.

[0084] S1013: Fine-tune the theoretical coordinate information according to the system data processing rules to obtain the actual coordinate information.

[0085] Among them, the system data processing rules include at least one of the following:

[0086] Rule 1: If the boundary coordinates of the theoretical cropping area are not integers, adjust the theoretical coordinate information (such as adjusting up and down and / or left and right) so that the boundary coordinates of the actual cropping area are integers.

[0087] Rule 2: If the boundary coordinates of the theoretical cropping area do not meet the set coordinate alignment condition, adjust the theoretical coordinate information (such as adjusting up and down and / or left and right) so that the boundary coordinates of the actual cropping area meet the set coordinate alignment condition.

[0088] This is because some devices, such as embedded systems, do not support floating-point operations, or even if they do, floating-point operations consume a large amount of computing resources and memory, so the coordinates are rounded. Or because the display device does not support the direct display of decimal coordinates, or for the sake of simplifying the display logic and improving the display efficiency, the coordinates are also rounded. Furthermore, the set coordinate alignment condition means that the device usually has alignment requirements for the boundary coordinates, such as requiring alignment with 2, or an even alignment requirement, that is, the boundary coordinates must be even, otherwise, the coordinates are adjusted for alignment to meet the set coordinate alignment condition.

[0089] In practical applications, the system data processing rules and the set coordinate alignment conditions can both be set according to the actual application scenario, and no restrictions are imposed here.

[0090] In one implementation, according to the system data processing rules, calculate the offset amount that needs to be adjusted for the boundary points of the theoretical cutting area, and according to this offset amount, offset and adjust the coordinates of all points in the theoretical cutting area to obtain the actual cutting area.

[0091] S1014: Cut the image to be processed according to the actual coordinate information to obtain the cutting area.

[0092] S1015: Obtain the cutting deviation according to the first coordinate and the second coordinate of the target point in the cutting area.

[0093] Among them, the cutting deviation includes the offset in the x dimension and the offset in the y dimension.

[0094] Refer to Figure 3 As shown, it is an example diagram of a cutting area. Figure 3 In, cut based on the target point to obtain Figure 3 the theoretical cutting area in, and then, fine-tune the theoretical cutting area to obtain Figure 3 the actual cutting area in. The coordinates of the target point in the theoretical cutting area (i.e., the first coordinate) are (x1, y1), and the coordinates in the actual cutting area (i.e., the second coordinate) are (x2, y2).

[0095] Furthermore, since the fine-tuning makes a consistent adjustment to all points in the theoretical cutting area with the same offset. For example, the abscissa of the boundary point of the theoretical cutting area is 101.5. Since it needs to be aligned to 102, the abscissa of this boundary point needs to be adjusted to 102. Then, the determined offset amount of the fine-tuning is 0.5, and all points in the theoretical cutting area need to be adjusted by 0.5. Therefore, the cutting deviation can also be determined based on the offset amount of any other point in the theoretical cutting area.

[0096] In one implementation, determine the first coordinate of any point in the theoretical cutting area in the theoretical cutting area and its second coordinate in the actual cutting area; obtain the cutting deviation according to the difference between the first coordinate and the second coordinate.

[0097] Step 102: Based on the cutting deviation and the magnification factor corresponding to the cutting area, perform coordinate adjustment on the area magnification image obtained by magnifying the cutting area to compensate for the coordinate offset of the target point caused by the cutting deviation.

[0098] In one implementation, when performing step 102, the following two methods can be adopted:

[0099] Method 1: Perform first-level magnification on the image to be processed.

[0100] Method 2: Perform multi-level magnification on the image to be processed.

[0101] It should be noted that when performing first-level magnification on the image to be processed, only one magnification factor is required to magnify the image, while for multi-level magnification of the image to be processed, it is used to perform multiple image magnifications continuously through multiple magnification factors to achieve magnification of the target total magnification for the image to be processed. The target total magnification is the product of each magnification factor. Each magnification factor is the magnification factor during the cropping area magnification at each level of magnification. That is to say, multi-level magnification means that n magnifications will be performed, and the m-th level of magnification is a certain level of magnification in the multi-level magnification. Both n and m are positive integers, n is the total number of levels of multi-level magnification, and m is the serial number of a certain level of magnification in the n-level magnification process. Each level of magnification includes the following steps: image cropping, determining the cropping deviation, determining the magnification deviation, magnifying the cropping area, and the last level of magnification also includes translation compensation. Therefore, in the embodiments of the present disclosure, the cropping area, cropping deviation, magnification deviation, and area-magnified image during the m-th level of magnification are the cropping area, cropping deviation, magnification deviation, and area-magnified image respectively obtained in each step of performing the m-th level of magnification.

[0102] In one implementation, to perform image magnification in the multi-level magnification manner, after obtaining the target total magnification, the target total magnification can be decomposed to obtain the corresponding multiple magnification factors. That is to say, the product of each magnification factor is the target total magnification.

[0103] For example, taking the target total magnification of 8X as an example, the 8X magnification is achieved by a combination of three consecutive 2X magnification factors.

[0104] Among them, the target total magnification and each magnification factor can be set according to the actual application scenario. Any two magnification factors can be the same or different, and no limitation is made here.

[0105] In one implementation, when executing Method 1 above, the following steps can be adopted:

[0106] S1021-1: In the case of performing first-level magnification on the image to be processed, magnify the cropping area according to the magnification factor corresponding to the cropping area to obtain an area-magnified image.

[0107] S1021-2: Determine the magnification deviation according to the product of the magnification factor corresponding to the cropping area and the cropping deviation.

[0108] S1021-3: Perform translation compensation on the area-magnified image according to the magnification deviation to obtain a target-magnified image.

[0109] The following combinationFigure 4 Description is made for Method 2, and an example is given for the method of multi-level image zooming. Refer to Figure 4 As shown, it is an example diagram of multi-level image zooming. Figure 4 In this example, first, according to the first magnification ratio (i.e., 2 times), the image in Fig. (a) is initially cropped, and the cropped area is magnified to obtain Fig. (b). Then, according to the second magnification ratio (i.e., 2 times), Fig. (b) is cropped again to obtain Fig. (c). Similarly, Fig. (c) is cropped and magnified to obtain Fig. (d), which is the target zoomed image. Finally, Fig. (d) can be displayed on the screen.

[0110] In one implementation, when performing the above Method 2, the following steps are executed:

[0111] S1022-1: According to the magnification ratio for magnifying the cropped area, the cropped area is magnified to obtain a region zoomed image, and the zooming deviation at the first-level zooming is determined based on the product of the magnification ratio for magnifying the cropped area and the cropping deviation.

[0112] That is to say, at the first level, the zooming deviation is obtained based on the product of the magnification ratio for magnifying the cropped area and the cropping deviation at the first-level zooming.

[0113] S1022-2: When m is a positive integer greater than 1, for the m-th level zooming in multi-level zooming, the following steps are executed:

[0114] S1022-21: The region zoomed image at the (m - 1)-th level zooming is cropped to obtain a new cropped area and its corresponding cropping deviation.

[0115] Except for the initial cropping, each subsequent cropping is performed on the magnified image (i.e., the region zoomed image at the previous level zooming) of the previous cropped area. Since there will be a cropping deviation in each image cropping and magnification, the cropped area and the cropping deviation for each level of zooming can be determined respectively based on a principle similar to that for determining the cropping deviation in the above Method 1.

[0116] For example, Figure 4 in this example, the cropping deviation of the cropped area in Fig. (a) is calculated, the cropping deviation of the cropped area in Fig. (b) is calculated, and the cropping deviation of the cropped area in Fig. (c) is calculated.

[0117] S1022-22: According to the magnification ratio corresponding to the new cropped area, the new cropped area is magnified to obtain a new region zoomed image.

[0118] That is to say, from m = 2 to m = n in sequence, S1022-21 and S1022-22 are executed in a loop to obtain the region zoomed image at each level of zooming in sequence.

[0119] S1022-23: When the m-th stage is the last stage in the multi-stage zooming, perform translational compensation on the new region zoomed image according to the cropping deviation and magnification factor corresponding to the cropping region obtained during each stage of zooming, to obtain the target zoomed image.

[0120] In one implementation, for the m-th stage of zooming in the multi-stage zooming, perform the following steps: Obtain the zooming deviation at the m-th stage of zooming according to the sum of the zooming deviation at the (m - 1)-th stage of zooming and the cropping deviation at the m-th stage of zooming, and the magnification factor corresponding to the cropping region obtained at the m-th stage of zooming.

[0121] Similarly, from m = 2 to m = n in sequence, loop and execute this step to obtain the zooming deviation at each stage of zooming in sequence.

[0122] When the m-th stage is the last stage in the multi-stage zooming, perform translational compensation on the region zoomed image obtained at the m-th stage of zooming according to the zooming deviation at the m-th stage of zooming.

[0123] For example, when the m-th stage is the second stage, obtain the deviation sum at the second stage of zooming according to the sum of the zooming deviation at the first stage of zooming and the cropping deviation at the second stage of zooming, and obtain the zooming deviation at the second stage of zooming according to the product of the deviation sum at the second stage of zooming and the magnification factor for magnifying the cropping region at the second stage of zooming.

[0124] For another example, when the m-th stage is the third stage, obtain the deviation sum at the third stage of zooming according to the sum of the zooming deviation at the second stage of zooming and the cropping deviation at the third stage of zooming, and obtain the zooming deviation at the third stage of zooming according to the product of the deviation sum at the third stage of zooming and the magnification factor for magnifying the cropping region at the third stage of zooming.

[0125] Taking three-stage zooming as an example (i.e., performing three magnifications in sequence), an example is given to illustrate the calculation of the zooming deviation in the x direction.

[0126] During the first stage of zooming, use the first magnification factor α to perform primary cropping on the image to be processed. Then the cropping deviation can be expressed as ΔX. After primary cropping and magnification, the first region zoomed image is obtained. The zooming deviation deltaX1 at the first stage of zooming is: ΔX * α.

[0127] During the second stage of zooming, on the basis of the zooming error at the first stage of zooming, use the second magnification factor α1 to perform cropping and magnification on the first region zoomed image again to obtain the second region zoomed image. The cropping deviation for the second cropping is ΔX1, and the corresponding deviation sum can be expressed as: (ΔX * α) + ΔX1. The zooming deviation deltaX2 at the second stage of zooming is: ((ΔX * α) + ΔX1) * α1.

[0128] When performing the third-level zoom, based on the zoom error of the second-level zoom, the magnification factor α2 is used to crop and magnify the second-region zoom image again to obtain the third-region zoom image. The cropping deviation of the third cropping is ΔX2, and the corresponding sum of deviations can be expressed as: ((ΔX * α) + ΔX1) * α1 + ΔX2. The zoom deviation deltaX3 during the third-level zoom is: ((((ΔX * α) + ΔX1) * α1 + ΔX2) * α2).

[0129] The final zoom deviation in the x direction calculated based on ΔX, ΔX1, and ΔX2 can be expressed as deltaX3. Similarly, the final zoom deviation in the y direction can also be calculated, which can be expressed as deltaY3, and will not be elaborated here.

[0130] The following is an example to illustrate the range of the zoom deviation. In an application scenario, α = 2, α1 = 2, α2 = 2, and the ranges of ΔX, ΔX1, and ΔX2 are all [-1, 1]. The unit can be pixels. Then, during the first-level zoom, the maximum zoom deviation result is: ±(1 * 2) = ±2. By analogy, during the second-level zoom, the maximum zoom deviation result is: ±(((1 * 2) + 1) * 2) = ±6. During the third-level zoom, the maximum zoom deviation result is: ±((((1 * 2) + 1) * 2) + 1) * 2 = ±14.

[0131] In an implementation manner, for each point in the region zoom image, the sum of the coordinates of the point and the zoom deviation is calculated to obtain the new coordinates of the point. If there is no corresponding pixel value for the point, the pixel value of the point can be determined based on the adjacent pixel values.

[0132] Refer to Figure 5 As shown, it is an example diagram of a target zoom image. Figure 5 It contains the region zoom image and the target zoom image. If the zoom deviation is (deltaX, deltaY), then based on (deltaX, deltaY), the region zoom image can be moved in the direction of the target zoom image, so as to correct the deviations of the region zoom image in the x and y directions and obtain the target zoom image after translation compensation.

[0133] Furthermore, when obtaining the target zoom image, any of the following methods can also be used:

[0134] Method 1: When the mth level is the last level, perform translation compensation on the cropping region during the last-level zoom according to the sum of deviations during the last-level zoom. Then, based on the corresponding magnification factor, magnify the cropping region after translation compensation to obtain the target zoom image.

[0135] Method 2: When zooming in at each level, according to the corresponding cropping deviation and magnification factor, perform translational compensation on the corresponding region zoomed image.

[0136] In one implementation, for each level of zooming, the following steps are performed:

[0137] Crop the target zoomed image when zooming in at the previous level to obtain the cropping region and cropping deviation when zooming in at the m-th level, calculate the product of the cropping deviation and the magnification factor when zooming in at the m-th level, and magnify the cropping region according to this magnification factor to obtain a region zoomed image, and perform translational compensation on the region zoomed image according to this product to obtain the target zoomed image when zooming in at the m-th level.

[0138] In an application scenario, it can be applied to a sight product. For example, when a user is hunting, the image can be clearly shown on the screen of the device, and an indication icon for pointing to the target object and the center of the indication icon, i.e., the target point, are also shown in the image. Then, the fixed-point zooming method can be adopted to magnify the image based on the magnification factor selected by the user and the target point, so that the relative position of the target point remains unchanged before and after the image is magnified, facilitating the user to stare at the target object (such as the hunting object) to view, and at the same time when magnifying the image, the position deviation of the target point can be reduced, improving the position accuracy of the target point.

[0139] In the embodiments of the present application, when locally magnifying an image, according to the cropping deviation of the cropping region for cropping the image, performing reverse translation on the magnified image of the cropping region can reduce the position deviation degree of each point (including the target point) in the image.

[0140] Based on the same inventive concept, an image processing device is also provided in the embodiments of the present disclosure. Since the principle of solving problems by the above device and equipment is similar to that of an image processing method, therefore, the implementation of the above device can refer to the implementation of the method, and the repeated parts will not be described again. The device can be applied to an electronic device. The present disclosure does not limit the type of the electronic device, and it can be any device type suitable for implementation, such as a terminal device and a server, etc., which will not be described again in the present disclosure. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by the processor of the electronic device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for running.

[0141] Refer to Figure 6 As shown, it is a structural block diagram of the image processing device in the embodiments of the present disclosure. In some implementations, the image processing device exemplified in the present disclosure includes:

[0142] The cropping unit 601 is configured to determine the cropping deviation caused by cropping according to the actual coordinate information of the cropping area obtained by cropping the image to be processed and the theoretical coordinate information required for cropping; the theoretical coordinate information is calculated according to the coordinates of the target point in the image to be processed and the magnification factor for magnifying the cropping area, so that the cropping area contains the target point.

[0143] The adjustment unit 602 is configured to perform coordinate adjustment on the area magnification image obtained by magnifying the cropping area based on the cropping deviation and the magnification factor corresponding to the cropping area, so as to compensate for the coordinate offset of the target point caused by the cropping deviation.

[0144] In one implementation, the cropping unit 601 is configured to:

[0145] Calculate the theoretical coordinate information according to the first coordinate of the target point in the image to be processed and the magnification factor corresponding to the cropping area;

[0146] Fine-tune the theoretical coordinate information according to the system data processing rules to obtain the actual coordinate information;

[0147] Crop the image to be processed according to the actual coordinate information to obtain the cropping area;

[0148] Obtain the cropping deviation according to the first coordinate and the second coordinate of the target point in the cropping area.

[0149] In one implementation, the adjustment unit 602 is configured to:

[0150] In the case of performing first-level magnification on the image to be processed, magnify the cropping area according to the magnification factor corresponding to the cropping area to obtain the area magnification image;

[0151] Determine the magnification deviation according to the product of the magnification factor corresponding to the cropping area and the cropping deviation;

[0152] Perform translational compensation on the area magnification image according to the magnification deviation.

[0153] In one implementation, the adjustment unit 602 is configured to:

[0154] In the case of performing multi-level magnification on the image to be processed, for the m-th level magnification in the multi-level magnification, perform the following steps:

[0155] Crop the area magnification image during the (m - 1)-th level magnification to obtain a new cropping area and its corresponding cropping deviation; m is a positive integer greater than 1;

[0156] Magnify the new cropping area according to the magnification factor corresponding to the new cropping area to obtain a new area magnification image;

[0157] When the m-th stage is the last stage in the multi-stage zoom, perform translational compensation on the new region zoomed image according to the cropping deviation and magnification factor corresponding to the cropping region obtained during zooming at each stage.

[0158] In one implementation, the adjustment unit 602 is configured to:

[0159] For the m-th stage zoom in the multi-stage zoom, perform the following steps:

[0160] Obtain the zoom deviation at the m-th stage zoom according to the sum of the zoom deviation at the (m - 1)-th stage zoom and the cropping deviation at the m-th stage zoom, and the magnification factor corresponding to the cropping region obtained during the m-th stage zoom;

[0161] When the m-th stage is the last stage in the multi-stage zoom, perform translational compensation on the region zoomed image obtained during the m-th stage zoom according to the zoom deviation at the m-th stage zoom.

[0162] In an embodiment of the present disclosure, there is also provided an electronic device, including:

[0163] A processor; and

[0164] A memory storing computer instructions for causing the processor to execute the method according to any of the above implementations.

[0165] In an embodiment of the present disclosure, there is provided a computer-readable storage medium storing computer instructions for causing a computer to execute the method according to any of the above implementations.

[0166] In an embodiment of the present disclosure, there is also provided a computer program product including computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code, and when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method according to any of the above implementations.

Claims

1. A method for image processing, characterized in that: The method is applied to an electronic device, comprising: Determining the cropping deviation caused by the cropping according to actual coordinate information of the cropping area obtained by cropping the image to be processed and theoretical coordinate information required for the cropping; the theoretical coordinate information is calculated according to the coordinates of the target point in the image to be processed and the magnification of the cropping area so that the cropped cropping area contains the target point; Based on the cropping deviation and the magnification corresponding to the cropping area, coordinate adjustment is performed on the regional zoom image obtained after the cropping area is enlarged to compensate for the coordinate offset of the target point caused by the cropping deviation.

2. The method according to claim 1, characterized in that The determining of the cropping deviation caused by the cropping based on the actual coordinate information of the cropping area obtained by cropping the image to be processed and the theoretical coordinate information required for the cropping includes: Calculating the theoretical coordinate information according to the first coordinate of the target point in the image to be processed and the magnification corresponding to the cropped area; According to the system data processing rules, the theoretical coordinate information is fine-tuned to obtain the actual coordinate information; According to the actual coordinate information, the image to be processed is cropped to obtain the cropped area; The clipping deviation is obtained according to the first coordinate and the second coordinate of the target point in the clipping area.

3. The method according to claim 1 or 2, characterized in that: The step of adjusting the coordinates of the regional zoom image obtained after the cropping area is enlarged based on the cropping deviation and the magnification corresponding to the cropping area includes: In the case of performing a first-level magnification change on the image to be processed, the cropped area is magnified according to the magnification ratio corresponding to the cropped area to obtain the regional magnification image; Determining the zoom deviation according to the product of the magnification corresponding to the cropping area and the cropping deviation; According to the zoom deviation, translation compensation is performed on the regional zoom image.

4. The method according to claim 3, characterized in that The step of adjusting the coordinates of the regional zoom image obtained after the cropping area is enlarged based on the cropping deviation and the magnification corresponding to the cropping area includes: In the case of performing multi-level magnification change on the image to be processed, for the mth level magnification change in the multi-level magnification change, the following steps are performed: The regional zoom image at the m-1th zoom level is cropped to obtain a new cropping area and its corresponding cropping deviation; m is a positive integer greater than 1; According to the magnification ratio corresponding to the new cropping area, the new cropping area is enlarged to obtain a new regional magnification image; When the mth level is the last level of the multi-level zooming, translation compensation is performed on the new regional zooming image according to the cropping deviation and magnification corresponding to the cropping area obtained at each level of zooming.

5. The method according to claim 4, characterized in that The method of performing translation compensation on the new regional zoom image according to the cropping deviation and magnification corresponding to the cropping area obtained at each level of zooming includes: For the mth level of magnification in the multi-level magnification, the following steps are performed: Obtaining the zoom deviation at the m-th zoom level according to the sum of the zoom deviation at the m-1th zoom level and the crop deviation at the m-th zoom level, and the magnification corresponding to the crop area obtained at the m-th zoom level; In the case where the mth level is the last level of the multi-level magnification change, translation compensation is performed on the regional magnification image obtained at the mth level magnification change according to the magnification deviation at the mth level magnification change.

6. An image processing device, characterized in that: The device comprises: A cropping unit, configured to determine a cropping deviation caused by the cropping according to actual coordinate information of a cropping area obtained by cropping the image to be processed and theoretical coordinate information required for the cropping; the theoretical coordinate information is calculated according to the coordinates of a target point in the image to be processed and a magnification ratio for magnifying the cropping area, so that the cropped cropping area contains the target point; The adjustment unit is used to adjust the coordinates of the regional zoom image obtained after enlarging the cropped area based on the cropping deviation and the magnification corresponding to the cropped area, so as to compensate for the coordinate offset of the target point caused by the cropping deviation.

7. The device according to claim 6, characterized in that The cutting unit is used for: Calculating the theoretical coordinate information according to the first coordinate of the target point in the image to be processed and the magnification corresponding to the cropped area; According to the system data processing rules, the theoretical coordinate information is fine-tuned to obtain the actual coordinate information; According to the actual coordinate information, the image to be processed is cropped to obtain the cropped area; The clipping deviation is obtained according to the first coordinate and the second coordinate of the target point in the clipping area.

8. The device according to claim 6 or 7, characterized in that The adjustment unit is used for: In the case of performing a first-level magnification change on the image to be processed, the cropped area is magnified according to the magnification ratio corresponding to the cropped area to obtain the regional magnification image; Determining the zoom deviation according to the product of the magnification corresponding to the cropping area and the cropping deviation; According to the zoom deviation, translation compensation is performed on the regional zoom image.

9. The device according to claim 8, characterized in that The adjustment unit is used for: In the case of performing multi-level magnification change on the image to be processed, for the mth level magnification change in the multi-level magnification change, the following steps are performed: Crop the regional zoom image at the m-1th zoom level to obtain a new cropping area and its corresponding cropping deviation; m is a positive integer greater than 1; According to the magnification ratio corresponding to the new cropping area, the new cropping area is enlarged to obtain a new regional magnification image; When the mth level is the last level of the multi-level zooming, translation compensation is performed on the new regional zooming image according to the cropping deviation and magnification corresponding to the cropping area obtained at each level of zooming.

10. The device according to claim 9, characterized in that The adjustment unit is used for: For the mth level of magnification in the multi-level magnification, the following steps are performed: Obtaining the zoom deviation at the m-th zoom level according to the sum of the zoom deviation at the m-1th zoom level and the crop deviation at the m-th zoom level, and the magnification corresponding to the crop area obtained at the m-th zoom level; In the case where the mth level is the last level of the multi-level magnification change, translation compensation is performed on the regional magnification image obtained at the mth level magnification change according to the magnification deviation at the mth level magnification change.

11. An electronic device, characterized in that: include: processor; as well as A memory storing computer instructions, wherein the computer instructions are used to enable the processor to execute the method according to any one of claims 1 to 5.