CN116228540A - Image processing method, device, storage medium and electronic equipment - Google Patents

Image processing method, device, storage medium and electronic equipment Download PDF

Info

Publication number
CN116228540A
CN116228540A CN202310246292.6A CN202310246292A CN116228540A CN 116228540 A CN116228540 A CN 116228540A CN 202310246292 A CN202310246292 A CN 202310246292A CN 116228540 A CN116228540 A CN 116228540A
Authority
CN
China
Prior art keywords
amplified
image
determining
width
region
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310246292.6A
Other languages
Chinese (zh)
Inventor
汪艳婷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zeku Technology Shanghai Corp Ltd
Original Assignee
Zeku Technology Shanghai Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zeku Technology Shanghai Corp Ltd filed Critical Zeku Technology Shanghai Corp Ltd
Priority to CN202310246292.6A priority Critical patent/CN116228540A/en
Publication of CN116228540A publication Critical patent/CN116228540A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/04845Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range for image manipulation, e.g. dragging, rotation, expansion or change of colour

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Studio Devices (AREA)

Abstract

The application discloses an image processing method, an image processing device, a storage medium and electronic equipment. The method comprises the following steps: acquiring a first size of an image to be amplified, and acquiring a second size of an amplified image corresponding to the image to be amplified; determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image; amplifying according to the target area to obtain a pixel value of a pixel position; from the pixel values, an enlarged image is determined. The method and the device can realize the image amplification processing.

Description

Image processing method, device, storage medium and electronic equipment
Technical Field
The application belongs to the technical field of electronics, and particularly relates to an image processing method, an image processing device, a computer readable storage medium and electronic equipment.
Background
Today, more and more electronic devices support high resolution displays, and in order to enable smaller raw images to fit into the high resolution display of the electronic device, an image needs to be enlarged.
Disclosure of Invention
The embodiment of the application provides an image processing method, an image processing device, a storage medium and electronic equipment, which can realize the amplification processing of an image.
In a first aspect, an embodiment of the present application provides an image processing method, including:
acquiring a first size of an image to be amplified, and acquiring a second size of an amplified image corresponding to the image to be amplified;
determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
amplifying according to the target area to obtain a pixel value of the pixel position;
and determining an amplified image according to the pixel value.
In a second aspect, an embodiment of the present application provides an image processing apparatus, including:
the size acquisition module is used for acquiring a first size of an image to be amplified and acquiring a second size of an amplified image corresponding to the image to be amplified;
the region determining module is used for determining a target region from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
the amplifying processing module is used for amplifying according to the target area to obtain a pixel value of the pixel position;
and the image determining module is used for determining an amplified image according to the pixel value.
In a third aspect, embodiments of the present application provide a computer-readable storage medium having stored thereon a computer program which, when executed on a computer, causes the computer to perform the image processing method provided by the embodiments of the present application.
In a fourth aspect, embodiments of the present application further provide an electronic device, including a memory, and a processor, where the processor is configured to execute the image processing method provided in the embodiments of the present application by calling a computer program stored in the memory.
In the embodiment of the application, a first size of an image to be amplified is obtained, and a second size of an amplified image corresponding to the image to be amplified is obtained; determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image; amplifying according to the target area to obtain a pixel value of the pixel position; and determining the amplified image according to the pixel value, so that the image can be amplified.
Drawings
The technical solution of the present application and the advantageous effects thereof will be made apparent from the following detailed description of the specific embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a flowchart of an image processing method according to an embodiment of the present application.
Fig. 2 to 7 are schematic views of a scenario of an image processing method according to an embodiment of the present application.
Fig. 8 is a schematic structural diagram of an image processing apparatus provided in an embodiment of the present application.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
It should be noted that the terms "first," "second," and "third," etc. in this application are used to distinguish between different objects and are not used to describe a particular order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to the particular steps or modules listed and certain embodiments may include additional steps or modules not listed or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The embodiment of the application provides an image processing method, an image processing device, a storage medium and electronic equipment. The main execution body of the image processing method may be the image processing apparatus provided in the embodiment of the present application, or an electronic device integrated with the image processing apparatus, where the image processing apparatus may be implemented in a hardware or software manner. The electronic device may be a device with an image processing capability, such as a smart phone, a tablet computer, a palm computer, a notebook computer, and the like, configured with a processor.
Referring to fig. 1, fig. 1 is a schematic flow chart of an image processing method according to an embodiment of the present application, where the flow may include:
in 101, a first size of an image to be magnified is obtained, and a second size of a magnified image corresponding to the image to be magnified is obtained.
The image to be amplified is an image to be amplified, and the amplified image corresponding to the image to be amplified is an image obtained after the image to be amplified is amplified.
It will be appreciated that the size of the magnified image is derived from the image to be magnified multiplied by the magnification ratio. Therefore, in this embodiment, the magnification ratio may be determined first, and then the size of the image to be magnified may be determined according to the size of the image to be magnified and the magnification ratio. Wherein the amplification ratio is greater than 1.
For example, assuming that the size of an image to be enlarged is 200×400 pixels and the enlargement ratio is 2, the size of the enlarged image is 400×800 pixels.
In 102, a target region is determined from the image to be magnified based on the first size, the second size, and the pixel locations in the magnified image where pixel values need to be determined.
It will be appreciated that after the size of the enlarged image is determined, the pixel value of each pixel location in the enlarged image is determined from the image to be enlarged, and thus the enlarged image is determined from the pixel value of each pixel location in the enlarged image. For example, assuming that the size of the enlarged image is 400×800 pixels, it is necessary to determine the pixel value of 320000 pixel positions, and after determining the pixel value of 32000 pixel positions, the enlarged image is obtained.
Where the pixel position is typically represented by coordinates (x, y) in a pixel coordinate system, x representing the abscissa of the pixel position and y representing the ordinate of the pixel position. The pixel coordinate system is a coordinate system established by taking the upper left corner of the image as an origin (0, 0), the horizontal coordinate of the behavior of the image, and the vertical coordinate of the column of the image.
For example, if the pixel value of the coordinate C1 in the enlarged image needs to be determined, the target area may be determined from the image to be enlarged according to the first size, the second size, and the coordinate C1.
For another example, if the pixel value of the coordinate C2 in the enlarged image needs to be determined, the target area may be determined from the image to be enlarged according to the first size, the second size, and the coordinate C2.
At 103, an amplification process is performed according to the target area, and a pixel value of the pixel position is obtained.
For example, as shown in fig. 2, if the target area A1 is determined from the image M1 to be amplified according to the first size, the second size and the coordinate C1, the pixel value P21 of the coordinate C1 may be obtained by performing the amplification processing according to the pixel values P11, P12, P13 and P14 of the target area A1 by using a corresponding amplification algorithm.
For another example, as shown in fig. 3, if the target area A2 is determined from the image M1 to be magnified according to the first size, the second size and the coordinate C2, the pixel value P22 of the coordinate C2 may be obtained by performing the magnification processing according to the pixel values P15, P16, P17 and P18 of the target area A2 by using a corresponding magnification algorithm.
It should be noted that, in the embodiments of the present application, the amplification algorithm used in the amplification process is not limited, and any amplification algorithm may be used. For example, the amplification algorithm employed in embodiments of the present application may be a bilinear interpolation algorithm.
It should be further noted that, in the embodiment of the present application, the pixel values of different pixel positions may be determined by using different amplification algorithms, or may be determined by using the same amplification algorithm.
It should also be noted that, in the embodiment of the present application, the size of the target area may be determined according to the requirement of the amplifying algorithm adopted in the embodiment of the present application. For example, if the magnification algorithm used in the embodiments of the present application requires data having a size of 2×2 matrix, the size of the target area is 2×2 pixels.
At 104, an enlarged image is determined from the pixel values.
In this embodiment, after determining the pixel value of each pixel position in the enlarged image through steps 101 to 103, the enlarged image may be determined according to the pixel value of each pixel position in the enlarged image.
In this embodiment, a first size of an image to be amplified is obtained, and a second size of an amplified image corresponding to the image to be amplified is obtained; determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image; amplifying according to the target area to obtain a pixel value of the pixel position; and determining the amplified image according to the pixel value, so that the image can be amplified.
In an alternative embodiment, determining the target area from the image to be enlarged according to the first size, the second size, and the pixel position in the enlarged image where the pixel value needs to be determined includes:
Determining a target position from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
and determining a target area from the image to be magnified according to the target position.
For example, the target position may be determined from the image to be amplified according to the first size, the second size, and the pixel position of the pixel value to be determined in the amplified image, and then the region with the target position as the center in the image to be amplified and the preset range is determined as the target region.
It should be noted that, in the embodiment of the present application, the size of the area in the preset range may be determined according to the requirement of the amplifying algorithm adopted in the embodiment of the present application. For example, if the amplification algorithm used in the embodiment of the present application requires data with a size of 6×8 matrix, the size of the area of the preset range is 6×8 pixels.
It should be further noted that, in the embodiment of the present application, the target position is not necessarily located at the exact center of the target area, and may be determined by those skilled in the art according to actual requirements. For example, assuming that the size of the target area needs to be 6×8 pixels, the target position may be the position of the 3 rd row and 4 th column in the target area, the position of the 4 th row and 5 th column in the target area, and so on. For another example, assuming that the size of the target area needs to be 4×4 pixels, the target position may be the position of the 2 nd row and the 2 nd column in the target area, the position of the 3 rd row and the 3 rd column in the target area, and so on. For another example, assuming that the size of the target area needs to be 2×2 pixels, the target position may be the 1 st row and 1 st column position in the target area, the 2 nd row and 2 nd column position in the target area, and so on.
In an alternative embodiment, the first size includes a first width and a first height, the second size includes a second width and a second height, the pixel location includes a first sub-pixel location and a second sub-pixel location, the target location includes a first sub-target location and a second sub-target location, and determining the target location from the image to be magnified based on the first size, the second size, and the pixel location in the magnified image where the pixel value is to be determined includes:
determining a first amplification factor according to the first width and the second width;
determining a first sub-target position from the image to be amplified according to the first amplification factor and the first sub-pixel position;
determining a second amplification factor based on the first height and the second height;
and determining a second sub-target position from the image to be amplified according to the second amplification factor and the second sub-pixel position.
For example, the first subpixel position is a first abscissa and the second subpixel position is a first ordinate. The first sub-target position is a second abscissa, and the second sub-target position is a second ordinate, and then the first magnification factor can be determined according to the first width and the second width, and the second abscissa is determined from the image to be magnified according to the first magnification factor and the first abscissa, and then the second magnification factor is determined according to the first height and the second height, and the second ordinate is determined from the image to be magnified according to the second magnification factor and the second sub-pixel position. Wherein the first abscissa and the first ordinate are coordinates in a pixel coordinate system established based on the enlarged image, and the second abscissa and the second ordinate are coordinates in a pixel coordinate system established based on the image to be enlarged.
It will be appreciated that, since the first abscissa and the first ordinate may indicate a specific pixel position in the enlarged image, and the second abscissa and the second ordinate may indicate a specific pixel position in the image to be enlarged, the pixel position to determine the pixel value according to a certain requirement in the enlarged image may determine the corresponding pixel position for performing the enlargement processing, that is, the target position, from the image to be enlarged, and then determine the target area from the image to be enlarged according to the target position.
In an alternative embodiment, determining the first amplification factor based on the first width and the second width includes:
acquiring a width coefficient;
determining a first amplification factor according to the width factor, the first width and the second width;
determining a first sub-target position from the image to be amplified according to the first amplification factor and the first sub-pixel position, including:
determining a first sub-target position from the image to be amplified according to the width coefficient, the first amplification coefficient and the first sub-pixel position;
determining a second amplification factor based on the first height and the second height, comprising:
acquiring a height coefficient;
Determining a second amplification factor according to the height factor, the first height and the second height;
determining a second sub-target position from the image to be amplified according to the second magnification factor and the second sub-pixel position, comprising:
and determining a second sub-target position from the image to be amplified according to the height coefficient, the second amplification coefficient and the second sub-pixel position.
Wherein the dimensions of the image include width and height. For example, assuming that the size of the image to be enlarged is 200×400 pixels, the width of the image to be enlarged, i.e., the first width is 200 pixels, and the height of the image to be enlarged, i.e., the first height is 400 pixels.
For example, the first amplification factor may be determined according to equation (1) based on the width factor, the first width, and the second width. Wherein, formula (1) is:
inv_scale_w = (in_width<<COORD_BIT)/out_width (1)
wherein inv_scale_w represents a first amplification factor, in_width represents a first width, coord_bit represents a width factor, and out_width represents a second width. The value of COORD_BIT can be set by a person skilled in the art according to actual requirements, and the larger the value of COORD_BIT is, the higher the amplification precision is, and the finer the amplification interpolation effect is. For example, COORD_BIT may have values of 12, 14, 15, etc.
The first sub-target position, i.e. the second abscissa, may be determined from the image to be magnified according to equation (2) based on the first magnification factor, the width factor, and the first sub-pixel position, i.e. the first abscissa.
src i = dst i ×inv_scale_w+(inv_scale_w>>1)-(1<<(COORD_BIT-1)) (2)
Wherein src is i Representing the second abscissa, dst i The first abscissa is represented, inv_scale_w represents the first amplification factor, and coord_bit represents the width factor.
The first amplification factor may be determined according to equation (3) based on the height factor, the first height, and the second height. Wherein, formula (3) is:
inv_scale_h = (in_height<<COORD_BIT)/out_height (3)
wherein inv_scale_h represents the second amplification factor, in_height represents the first height, COORD_BIT represents the height factor, and out_height represents the second height. The value of COORD_BIT can be set by a person skilled in the art according to actual requirements, and the larger the value of COORD_BIT is, the higher the amplification precision is, and the finer the amplification interpolation effect is. For example, COORD_BIT may have values of 12, 14, 15, etc.
The first sub-target position, i.e. the second ordinate, may be determined from the image to be magnified according to equation (4) based on the first magnification factor, the height factor, and the second sub-pixel position, i.e. the first ordinate.
src j = dst j ×inv_scale_h+(inv_scale_h>>1)-(1<<(COORD_BIT-1)) (4)
Wherein src is j Representing the second ordinate, dst j Representing the first ordinate, inv_scale_h represents the second amplification factor and coord_bit represents the height factor.
In an alternative embodiment, acquiring a first size of an image to be magnified and acquiring a second size of a magnified image corresponding to the image to be magnified includes:
if the width of the amplified image is smaller than or equal to the preset width, a first size of the image to be amplified is obtained, and a second size of the amplified image corresponding to the image to be amplified is obtained.
In general, before an image is enlarged, the image to be enlarged needs to be buffered in a Static Random-Access Memory (SRAM), and then the image needs to be taken out from the SRAM to be enlarged when the image is enlarged. The width of the buffered image affects the area of the SRAM, that is, the larger the width of the buffered image is, the larger the area of the SRAM is, so that the circuit cost is higher and the power consumption is higher. Based on this, in this embodiment, an appropriate image width may be set as a preset width, and the SRAM is designed according to the preset width, so that the area of the SRAM is relatively appropriate, so as to save circuit cost and reduce power consumption.
Since the image for amplifying is first buffered in the SRAM, and then the image is taken out from the SRAM for amplifying, it is known that the width of the image for amplifying is required to be less than or equal to the preset width.
In an alternative embodiment, the image processing method further includes:
if the width of the amplified image is larger than the preset width, determining initial positions of a plurality of amplified regions included in the amplified image in the width direction according to the width of the amplified image and the preset width, wherein the amplified regions form the amplified image;
determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region;
Amplifying according to the size of each region to be amplified, the size of the amplified region corresponding to each region to be amplified and each region to be amplified to obtain each amplified region;
and combining each amplified region to obtain an amplified image.
Since the image for performing the amplifying process is first cached in the SRAM, and then the image is taken out from the SRAM for performing the amplifying process, it is known that the width of the image for performing the amplifying process is required to be less than or equal to the preset width.
For example, as shown in fig. 4, assuming that the width of the enlarged image M2 is 4096 and the preset width is 1024, the enlarged image M2 may be divided into a plurality of enlarged areas a31, a32, a33, and a34 having 1024 widths.
For another example, as shown in fig. 5, assuming that the width of the enlarged image M2 is 4603 and the preset width is 1024, the enlarged image M2 may be divided into a plurality of enlarged areas a41, a42, a43, and a44 having a width of 1024 and an enlarged area a45 having a width of 512.
Taking the enlarged area a32 as an example, the starting position of the enlarged area a32 in the width direction, that is, the abscissa of the starting position of the enlarged area a32 in the width direction in the pixel coordinate system established based on the enlarged image M2, can be determined, and the area to be enlarged corresponding to the enlarged area a33 is determined from the image to be enlarged according to the abscissa; according to the region to be amplified, the pixel value of the amplified region a32 can be obtained, the pixel values of the amplified regions a31, a32, a33, and a34 can be obtained in the same manner as the pixel value of the amplified region a32, and the amplified regions a31, a32, a33, and a34, for which the pixel values are determined, can be combined to obtain an amplified image.
Specifically, performing the amplifying process according to the area to be amplified to obtain the pixel value of the amplified area a32 may include: determining a sub-area to be amplified from the area to be amplified A32 according to the size of the area to be amplified, the size of the area A32 after amplification and the pixel position of the pixel value to be determined in the area 32 after amplification; amplifying according to the sub-region to be amplified to obtain a pixel value of the pixel position; the enlarged region a32 is determined from the pixel value of the pixel position. It will be appreciated that the specific implementation of this process may be found in the previous embodiments and will not be described here again.
In an optional embodiment, before determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the starting position of each amplified region, the method further includes:
determining end positions of a plurality of amplified regions included in the amplified image in the width direction according to the second width and the preset width;
determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the starting position of each amplified region, including:
determining an amplification factor according to the width of the image to be amplified and the width of the amplified image;
determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region;
determining a target end position corresponding to each amplified region according to the amplification coefficient and the end position of each amplified region;
and determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target ending position corresponding to each amplified region.
Wherein the start position and the end position of each enlarged region in the width direction are the abscissa of each enlarged region in a pixel coordinate system established with the enlarged image.
For example, assuming that the enlarged image M2 is divided into a plurality of enlarged areas a31, a32, a33, and a34 having a width 1024 to obtain an area to be enlarged corresponding to the enlarged area a32 as an example, the enlargement factor may be determined according to the formula (1) from the width of the image to be enlarged and the width of the image after enlargement. That is, the amplification factor in this embodiment is the first amplification factor described above.
It will be appreciated that the start position of the enlarged area a32 in the width direction is 1025 and the end position in the width direction is 2048, then 1025 can be taken as dst i The abscissa of the start position of the region to be enlarged corresponding to the enlarged region a32 in the width direction in the image coordinate system established from the image to be enlarged is taken as src i The above-determined magnification factor is taken as inv_scale_w, and according to the formula (2), the abscissa of the starting position of the region to be magnified corresponding to the region A32 to be magnified in the width direction in the image coordinate system established according to the image to be magnified is obtainedThe abscissa is used as a target starting position corresponding to the amplified region a32, and so on, a target ending position corresponding to the amplified region a32 can be determined in the same manner as described above, and the region to be amplified corresponding to the amplified region a32 can be determined from the image to be amplified according to the target starting position and the target ending position. By analogy, the regions to be amplified corresponding to the amplified regions a31, a33, and a34 can also be determined in the same manner as described above.
In an optional embodiment, before determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the starting position of each amplified region, the method further includes:
determining the widths of a plurality of amplified regions included in the amplified image according to the second width and the preset width;
determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the starting position of each amplified region, including:
determining an amplification factor according to the width of the image to be amplified and the width of the amplified image;
determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region;
determining the target width corresponding to each amplified region according to the amplification coefficient and the width of each amplified region;
and determining the region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target width corresponding to each amplified region.
For example, assuming that the enlarged image M2 is divided into a plurality of enlarged areas a31, a32, a33, and a34 having a width 1024 to obtain an area to be enlarged corresponding to the enlarged area a32 as an example, the enlargement factor may be determined according to the formula (1) from the width of the image to be enlarged and the width of the image after enlargement. That is, the amplification factor in this embodiment is the first amplification factor described above.
It will be appreciated that the starting position of the enlarged area A32 is on the abscissa1025, the ending position being 2048 on the abscissa, then the abscissa 1025 can be taken as dst i The abscissa of the start position of the region to be enlarged corresponding to the enlarged region a32 in the width direction in the image coordinate system established from the image to be enlarged is taken as src i The determined amplification factor is taken as inv_scale_w, and according to the formula (2), the abscissa of the starting position of the region to be amplified corresponding to the region A32 after amplification in the width direction in the image coordinate system established according to the image to be amplified is obtained, and the abscissa is taken as the target starting position corresponding to the region A32 after amplification; the width of the amplified region a32 may be taken as out_width, and the width of the region to be amplified corresponding to the amplified region a32 may be taken as in_width, and the width of the region to be amplified corresponding to the amplified region a32 may be obtained according to the formula (1); the region to be enlarged corresponding to the region a32 after enlargement can be determined from the image to be processed based on the target start position and the target width, which are the target start position corresponding to the region a32 after enlargement and the width of the region to be enlarged corresponding to the region a32 after enlargement. By analogy, the regions to be amplified corresponding to the amplified regions a31, a33, and a34 can also be determined in the same manner as described above.
In the embodiment of the present application, only the image to be amplified and the amplified image are divided in the width direction, but not in the height direction, that is, the height of each region to be amplified is the same as that of the image to be amplified, and the height of each region to be amplified is the same as that of the image to be amplified.
In an alternative embodiment, for the first region after zooming in, for example, the zoomed-in region a31, the corresponding target starting position may be directly determined as 0, and then, after determining the corresponding target ending position or target width according to the above manner, the region to be zoomed in may be determined from the image to be zoomed in according to the target starting position and target ending position or target width. For the last amplified region, for example, the amplified region a34, the target end position corresponding to the amplified region a34 may be directly determined as the position of the last column of the image to be amplified, for example, assuming that the width of the image to be amplified is 2048, the target end position is 2048, and after determining the target start position corresponding to the amplified region a34, the region to be amplified corresponding to the amplified region a34 is determined according to the target start position and the target end position; after determining the target width corresponding to the enlarged region a34, the region to be enlarged corresponding to the enlarged region a34 may be determined according to the target end position and the target width, and for example, assuming that the target width is 512, the region to be enlarged corresponding to the enlarged region a34 may be determined as a region having a start position of 1537 and an end position of 2048 in the width direction in the image to be enlarged.
In an alternative embodiment, as shown in fig. 6, the embodiment of the present application may further perform register configuration according to the image processing method described above.
The first step: a first register configuration module (register cfg) configures the size of the image input and the image output by the magnification processing module. Wherein the input image may be a target area determined from the image to be magnified, and the size of the input image may be determined by the size required by the magnification algorithm. The output image may be an enlarged image. If the width of the amplified image is larger than the preset width, the output image is each amplified region included in the amplified image, and the register cfg is further configured with the starting position and the ending position or the width of the amplified region output by the amplifying processing module.
And a second step of: the second register configuration module (region rdcfg) configures the starting position and the size of the image output by the storage device, and can realize the amplification processing from any position of the image. For example, when the width of the enlarged image is smaller than or equal to the preset width, the starting position and the size of the output image are the starting position and the size of the line where the target area determined from the image to be enlarged is located in the image to be enlarged.
And a third step of: the third register configuration module (register wrcfg) configures a start position and a size of an image input from the storage device in a width direction. When the width of the amplified image is smaller than or equal to the preset width, the starting position and the size of the image input by the storage device are the starting position and the size of the image to be amplified in the width direction. The above-mentioned start positions are all positions in an image coordinate system established based on the image to be enlarged.
Fourth step: after the register configuration is completed, the image is input into the storage device, the amplifying processing module actively reads the image configured in the storage device, and if interpolation calculation needs to be performed by using a 6×8 matrix, the SRAM with the width of 6 rows of images is obtained for buffering, as shown in fig. 7.
Fifth step: after the 6×8 matrix data is obtained, performing amplification processing calculation through an amplification processing module, storing the calculated data into a storage device, and completing the amplification processing of the area to be amplified once through a sliding window.
Sixth step: when the processing of the area to be amplified is finished last time, the internal logic of the amplifying processing module records the last finishing parameter, and when the second processing is carried out, the last finishing position +1 can be directly used as the starting position of the area to be amplified for amplifying, so that the amplified area output to the storage device after the amplifying processing can be combined without any clipping to form an amplified image, and meanwhile, the record of the starting position register input into the area to be amplified is saved.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present application. The image processing apparatus 300 includes: a size acquisition module 301, a region determination module 302, an enlargement processing module 303, and an image determination module 304.
The size obtaining module 301 is configured to obtain a first size of an image to be enlarged, and obtain a second size of an enlarged image corresponding to the image to be enlarged.
The region determining module 302 is configured to determine a target region from the image to be enlarged according to the first size, the second size, and a pixel position in the enlarged image where a pixel value needs to be determined.
And the amplification processing module 303 is configured to perform amplification processing according to the target area, so as to obtain a pixel value of the pixel position.
An image determining module 304 is configured to determine an enlarged image according to the pixel values.
In an alternative embodiment, the region determination module 302 may be configured to: determining a target position from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image; and determining a target area from the image to be amplified according to the target position.
In an alternative embodiment, the first dimension includes a first width and a first height, the second dimension includes a second width and a second height, the pixel location includes a first sub-pixel location and a second sub-pixel location, the target location includes a first sub-target location and a second sub-target location, and the region determination module 302 may be configured to: determining a first amplification factor according to the first width and the second width; determining a first sub-target position from the image to be amplified according to the first amplification coefficient and the first sub-pixel position; determining a second amplification factor according to the first height and the second height; and determining a second sub-target position from the image to be amplified according to the second amplification factor and the second sub-pixel position.
In an alternative embodiment, the region determination module 302 may be configured to: acquiring a width coefficient; determining a first amplification factor according to the width factor, the first width and the second width; determining a first sub-target position from the image to be amplified according to the width coefficient, the first amplification coefficient and the first sub-pixel position; acquiring a height coefficient; determining a second amplification factor according to the height factor, the first height and the second height; and determining a second sub-target position from the image to be amplified according to the height coefficient, the second amplification coefficient and the second sub-pixel position.
In an alternative embodiment, the size acquisition module 301 may be configured to: and if the width of the amplified image is smaller than or equal to the preset width, acquiring a first size of the image to be amplified, and acquiring a second size of the amplified image corresponding to the image to be amplified.
In an alternative embodiment, the region determination module 303 may be configured to: if the width of the amplified image is larger than a preset width, determining initial positions of a plurality of amplified regions included in the amplified image in the width direction according to the width of the amplified image and the preset width, wherein the amplified regions form the amplified image; determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region;
The amplification processing module 304 may be configured to: amplifying according to the size of each region to be amplified, the size of the amplified region corresponding to each region to be amplified and each region to be amplified to obtain each amplified region; and combining each amplified region to obtain the amplified image.
In an alternative embodiment, the region determination module 303 may be configured to: determining end positions of a plurality of amplified regions included in the amplified image in the width direction according to the second width and the preset width; determining an amplification factor according to the width of the image to be amplified and the width of the amplified image; determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region; determining a target end position corresponding to each amplified region according to the amplification coefficient and the end position of each amplified region; and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target ending position corresponding to each amplified region.
In an alternative embodiment, the region determination module 303 may be configured to: determining the width of a plurality of amplified regions included in the amplified image according to the second width and the preset width, and determining an amplification factor according to the width of the image to be amplified and the width of the amplified image; determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region; determining a target width corresponding to each amplified region according to the amplification coefficient and the width of each amplified region; and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target width corresponding to each amplified region.
The present embodiment provides a computer-readable storage medium having stored thereon a computer program which, when executed on a computer, causes the computer to execute the image processing method as provided in the present embodiment.
The embodiment of the application also provides electronic equipment, which comprises a memory and a processor, wherein the processor is used for executing the image processing method provided by the embodiment by calling the computer program stored in the memory.
For example, the electronic device may be a mobile terminal such as a tablet computer or a smart phone. Referring to fig. 9, fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
The electronic device 400 may include a processor 401, memory 402, and the like. It will be appreciated by those skilled in the art that the electronic device structure shown in fig. 9 is not limiting of the electronic device and may include more or fewer components than shown, or may combine certain components, or may be arranged differently, such as the electronic device 400 may also include a screen.
The processor 401 is a control center of the electronic device, connects various parts of the entire electronic device using various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing application programs stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device.
Memory 402 may be used to store applications and data. The memory 402 stores application programs including executable code. Applications may constitute various functional modules. The processor 401 executes various functional applications and data processing by running application programs stored in the memory 402.
In this embodiment, the processor 401 in the electronic device loads executable codes corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 executes the application programs stored in the memory 402, so as to implement:
acquiring a first size of an image to be amplified, and acquiring a second size of an amplified image corresponding to the image to be amplified;
determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
amplifying according to the target area to obtain a pixel value of the pixel position;
and determining an amplified image according to the pixel value.
In an alternative embodiment, when the processor 401 executes the pixel positions in the enlarged image, where the pixel values need to be determined according to the first size, the second size, and the enlarged image, the determining the target area from the image to be enlarged may be performed: determining a target position from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image; and determining a target area from the image to be amplified according to the target position.
In an alternative embodiment, the first size includes a first width and a first height, the second size includes a second width and a second height, the pixel location includes a first sub-pixel location and a second sub-pixel location, the target location includes a first sub-target location and a second sub-target location, and the processor 401 performs the determining of the target location from the image to be enlarged based on the first size, the second size, and the pixel location in the enlarged image where the pixel value needs to be determined, may perform: determining a first amplification factor according to the first width and the second width; determining a first sub-target position from the image to be amplified according to the first amplification coefficient and the first sub-pixel position; determining a second amplification factor according to the first height and the second height; and determining a second sub-target position from the image to be amplified according to the second amplification factor and the second sub-pixel position.
In an alternative embodiment, when the processor 401 executes the determining the first amplification factor according to the first width and the second width, the determining may be performed: acquiring a width coefficient; determining a first amplification factor according to the width factor, the first width and the second width; the processor 401 may execute the determining, according to the first amplification factor and the first sub-pixel position, the first sub-target position from the image to be amplified, by: determining a first sub-target position from the image to be amplified according to the width coefficient, the first amplification coefficient and the first sub-pixel position; processor 401 may perform the determining the second amplification factor according to the first height and the second height by: acquiring a height coefficient; determining a second amplification factor according to the height factor, the first height and the second height; the processor 401 may execute, when executing the determining, according to the second magnification factor and the second sub-pixel position, the second sub-target position from the image to be magnified, the method may execute: and determining a second sub-target position from the image to be amplified according to the height coefficient, the second amplification coefficient and the second sub-pixel position.
In an alternative embodiment, when the processor 401 performs the acquiring the first size of the image to be enlarged and acquires the second size of the enlarged image corresponding to the image to be enlarged, it may perform: and if the width of the amplified image is smaller than or equal to the preset width, acquiring a first size of the image to be amplified, and acquiring a second size of the amplified image corresponding to the image to be amplified.
In an alternative embodiment, the processor 401 may further perform: if the width of the amplified image is larger than a preset width, determining initial positions of a plurality of amplified regions included in the amplified image in the width direction according to the width of the amplified image and the preset width, wherein the amplified regions form the amplified image; determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region; amplifying according to the size of each region to be amplified, the size of the amplified region corresponding to each region to be amplified and each region to be amplified to obtain each amplified region; and combining each amplified region to obtain the amplified image.
In an optional embodiment, before the processor 401 executes the determining, from the image to be amplified, the area to be amplified corresponding to each of the areas to be amplified according to the starting position of each of the areas to be amplified, the method may further execute: determining end positions of a plurality of amplified regions included in the amplified image in the width direction according to the second width and the preset width; when the processor 401 executes the determining, from the image to be amplified, the area to be amplified corresponding to each of the areas to be amplified according to the starting position of each of the areas to be amplified, the steps may be performed: determining an amplification factor according to the width of the image to be amplified and the width of the amplified image; determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region; determining a target end position corresponding to each amplified region according to the amplification coefficient and the end position of each amplified region; and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target ending position corresponding to each amplified region.
In an optional embodiment, before the processor 401 executes the determining, from the image to be amplified, the area to be amplified corresponding to each of the areas to be amplified according to the starting position of each of the areas to be amplified, the method may further execute: determining the width of a plurality of amplified regions included in the amplified image according to the second width and the preset width; when the processor 401 executes the determining, from the image to be amplified, the area to be amplified corresponding to each of the areas to be amplified according to the starting position of each of the areas to be amplified, the steps may be performed: determining an amplification factor according to the width of the image to be amplified and the width of the amplified image; determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region; determining a target width corresponding to each amplified region according to the amplification coefficient and the width of each amplified region; and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target width corresponding to each amplified region.
In the foregoing embodiments, the descriptions of the embodiments are focused on, and the portions of an embodiment that are not described in detail in the foregoing embodiments may be referred to the detailed description of the image processing method, which is not repeated herein.
The image processing device provided in the embodiment of the present application belongs to the same concept as the image processing method in the above embodiment, and any method provided in the image processing method embodiment may be run on the image processing device, and detailed implementation processes of the method are shown in the image processing method embodiment, which is not repeated herein.
It should be noted that, for the image processing method according to the embodiment of the present application, it will be understood by those skilled in the art that all or part of the flow of implementing the image processing method according to the embodiment of the present application may be implemented by controlling related hardware through a computer program, where the computer program may be stored in a computer readable storage medium, such as a memory, and executed by at least one processor, and the execution may include the flow of the embodiment of the image processing method. The computer readable storage medium may be a magnetic disk, an optical disk, a Read Only Memory (ROM), a random access Memory (RAM, random Access Memory), etc.
It will be appreciated that in the specific embodiments of the present application, related data such as application usage behavior data, logs, etc. are related to user information, and when the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data is required to comply with related laws and regulations and standards of related countries and regions.
For the image processing apparatus of the embodiment of the present application, each functional module may be integrated into one processing chip, or each module may exist alone physically, or two or more modules may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules, if implemented as software functional modules and sold or used as a stand-alone product, may also be stored on a computer readable storage medium such as read-only memory, magnetic or optical disk, etc.
The foregoing describes in detail an image processing method, apparatus, storage medium and electronic device provided in the embodiments of the present application, and specific examples are applied to illustrate principles and implementations of the present application, where the foregoing description of the embodiments is only used to help understand the method and core idea of the present application; meanwhile, as those skilled in the art will vary in the specific embodiments and application scope according to the ideas of the present application, the contents of the present specification should not be construed as limiting the present application in summary.

Claims (11)

1. An image enlarging method, comprising:
acquiring a first size of an image to be amplified, and acquiring a second size of an amplified image corresponding to the image to be amplified;
determining a target area from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
amplifying according to the target area to obtain a pixel value of the pixel position;
and determining an amplified image according to the pixel value.
2. The image magnification method according to claim 1, wherein the determining the target area from the image to be magnified according to the first size, the second size, and the pixel position in the magnified image where the pixel value needs to be determined includes:
determining a target position from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
and determining a target area from the image to be amplified according to the target position.
3. The image enlargement method according to claim 2, wherein the first size includes a first width and a first height, the second size includes a second width and a second height, the pixel position includes a first sub-pixel position and a second sub-pixel position, the target position includes a first sub-target position and a second sub-target position, the determining the target position from the image to be enlarged based on the first size, the second size, and the pixel position in the enlarged image where the pixel value needs to be determined includes:
Determining a first amplification factor according to the first width and the second width;
determining a first sub-target position from the image to be amplified according to the first amplification coefficient and the first sub-pixel position;
determining a second amplification factor according to the first height and the second height;
and determining a second sub-target position from the image to be amplified according to the second amplification factor and the second sub-pixel position.
4. The image magnification method according to claim 3, wherein the determining a first magnification coefficient according to the first width and the second width comprises:
acquiring a width coefficient;
determining a first amplification factor according to the width factor, the first width and the second width;
the determining, according to the first amplification factor and the first sub-pixel position, a first sub-target position from the image to be amplified includes:
determining a first sub-target position from the image to be amplified according to the width coefficient, the first amplification coefficient and the first sub-pixel position;
said determining a second amplification factor from said first height and said second height comprises:
Acquiring a height coefficient;
determining a second amplification factor according to the height factor, the first height and the second height;
the determining, according to the second magnification factor and the second sub-pixel position, a second sub-target position from the image to be magnified includes:
and determining a second sub-target position from the image to be amplified according to the height coefficient, the second amplification coefficient and the second sub-pixel position.
5. The image magnification method according to claim 1, wherein the acquiring a first size of the image to be magnified and acquiring a second size of the magnified image corresponding to the image to be magnified includes:
and if the width of the amplified image is smaller than or equal to the preset width, acquiring a first size of the image to be amplified, and acquiring a second size of the amplified image corresponding to the image to be amplified.
6. The image enlargement method according to claim 5, further comprising:
if the width of the amplified image is larger than a preset width, determining initial positions of a plurality of amplified regions included in the amplified image in the width direction according to the width of the amplified image and the preset width, wherein the amplified regions form the amplified image;
Determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region;
amplifying according to the size of each region to be amplified, the size of the amplified region corresponding to each region to be amplified and each region to be amplified to obtain each amplified region;
and combining each amplified region to obtain the amplified image.
7. The method according to claim 6, wherein before determining the region to be enlarged corresponding to each of the enlarged regions from the image to be enlarged according to the start position of each of the enlarged regions, further comprising:
determining end positions of a plurality of amplified regions included in the amplified image in the width direction according to the second width and the preset width;
and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region, including:
determining an amplification factor according to the width of the image to be amplified and the width of the amplified image;
Determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region;
determining a target end position corresponding to each amplified region according to the amplification coefficient and the end position of each amplified region;
and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target ending position corresponding to each amplified region.
8. The method according to claim 6, wherein before determining the region to be enlarged corresponding to each of the enlarged regions from the image to be enlarged according to the start position of each of the enlarged regions, further comprising:
determining the width of a plurality of amplified regions included in the amplified image according to the second width and the preset width;
and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the initial position of each amplified region, including:
determining an amplification factor according to the width of the image to be amplified and the width of the amplified image;
Determining a target starting position corresponding to each amplified region according to the amplification coefficient and the starting position of each amplified region;
determining a target width corresponding to each amplified region according to the amplification coefficient and the width of each amplified region;
and determining a region to be amplified corresponding to each amplified region from the image to be amplified according to the target starting position and the target width corresponding to each amplified region.
9. An image enlarging apparatus, comprising:
the size acquisition module is used for acquiring a first size of an image to be amplified and acquiring a second size of an amplified image corresponding to the image to be amplified;
the region determining module is used for determining a target region from the image to be amplified according to the first size, the second size and the pixel position of the pixel value to be determined in the amplified image;
the amplifying processing module is used for amplifying according to the target area to obtain a pixel value of the pixel position;
and the image determining module is used for determining an amplified image according to the pixel value.
10. A computer-readable storage medium, in which a computer program is stored which, when run on a computer, causes the computer to perform the image processing method of any one of claims 1 to 8.
11. An electronic device comprising a processor and a memory, the memory having stored therein a computer program, the processor being operable to perform the image processing method of any of claims 1 to 8 by invoking the computer program stored in the memory.
CN202310246292.6A 2023-03-14 2023-03-14 Image processing method, device, storage medium and electronic equipment Pending CN116228540A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310246292.6A CN116228540A (en) 2023-03-14 2023-03-14 Image processing method, device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310246292.6A CN116228540A (en) 2023-03-14 2023-03-14 Image processing method, device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN116228540A true CN116228540A (en) 2023-06-06

Family

ID=86569388

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310246292.6A Pending CN116228540A (en) 2023-03-14 2023-03-14 Image processing method, device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN116228540A (en)

Similar Documents

Publication Publication Date Title
CN109298909B (en) Window adjusting method, mobile terminal and computer readable storage medium
EP2874054B1 (en) Application text adjusting method, device, and terminal
CN108537729B (en) Image stepless zooming method, computer device and computer readable storage medium
AU2013217637B2 (en) Overscan support
CN103336787B (en) A kind of method and apparatus for scaling webpage
CN111813300A (en) Screen capture method and device
CN115237522A (en) Page self-adaptive display method and device
CN113963072B (en) Binocular camera calibration method and device, computer equipment and storage medium
US20060204138A1 (en) Image scaling device using a single line memory and a scaling method thereof
CN116228540A (en) Image processing method, device, storage medium and electronic equipment
CN114339072A (en) Image processing circuit, method and electronic device
CN114491309A (en) Picture processing method and device
CN115829846A (en) Image processing method, image processing device, electronic equipment and storage medium
JP2001166754A (en) Display system
US20220075583A1 (en) Information processing method, server, terminal, and computer storage medium
WO2020167360A1 (en) Image processor complex transfer functions
CN111325333A (en) Data processing method, neural network processor, storage medium, and electronic device
CN112463280B (en) Image generation method, device, electronic equipment and computer readable storage medium
CN113721818B (en) Image processing method, device, equipment and computer readable storage medium
CN116594582B (en) Image display method, apparatus, computer device and storage medium
CN109886886B (en) Image restoration method and device
CN117492577B (en) Lightweight word stock display method and device, microprocessor and electronic equipment
US20090015592A1 (en) Display with efficient memory usage
CN110211534B (en) Image display method, image display device, controller and storage medium
CN117764819A (en) Image processing method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination