WO2024055676A1 - 图像压缩方法、装置、计算机设备及计算机可读存储介质 - Google Patents

图像压缩方法、装置、计算机设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2024055676A1
WO2024055676A1 PCT/CN2023/102672 CN2023102672W WO2024055676A1 WO 2024055676 A1 WO2024055676 A1 WO 2024055676A1 CN 2023102672 W CN2023102672 W CN 2023102672W WO 2024055676 A1 WO2024055676 A1 WO 2024055676A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
value
pixel
compressed
target
Prior art date
Application number
PCT/CN2023/102672
Other languages
English (en)
French (fr)
Inventor
陈冰
Original Assignee
深圳Tcl新技术有限公司
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 深圳Tcl新技术有限公司 filed Critical 深圳Tcl新技术有限公司
Publication of WO2024055676A1 publication Critical patent/WO2024055676A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding

Definitions

  • the present application relates to the field of image compression technology, and specifically to an image compression method, device, computer equipment and computer-readable storage medium.
  • Embodiments of the present application provide an image compression method, device, computer equipment, and computer-readable storage medium, which can improve the clarity of compressed images.
  • An image compression method including:
  • Obtain the image to be compressed, and the image to be compressed includes the target object
  • an image compression device including:
  • the acquisition unit can be used to acquire the image to be compressed, and the image to be compressed includes the target object;
  • the determination unit can be used to determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of the pixels in the image to be compressed;
  • the compression unit can be used to obtain the compression parameters corresponding to each image feature region, and perform compression processing on each image feature region according to the compression parameters corresponding to each image feature region to obtain a compressed image region;
  • the generation unit can be used to generate a compressed image according to the compressed image area.
  • the multiple image feature areas include a first image feature area, a second image feature area, and a third image feature area; the determination unit may be used to determine the target object according to the channel value of the pixel in the image to be compressed. Perform boundary recognition to determine the first image feature area from the image to be compressed; perform feature recognition on the target object based on the channel values of the pixels in the first image feature area to extract the second image feature area from the first image feature area ; According to the first image feature area, determine the third image feature area from the image to be compressed, and the third image feature area does not contain the target object.
  • the determination unit may be configured to determine the grayscale image of the image to be compressed based on the channel values of the pixels in the image to be compressed; and identify the object of the target object based on the grayscale values of the pixels in the grayscale image. Boundary; according to the object boundary, extract the first image feature area that matches the target object from the image to be compressed.
  • the determining unit may be used to determine the pixel type of the pixels in the image to be compressed; according to The pixel type determines the grayscale calculation strategy corresponding to the pixel; according to the channel value of the pixel, the grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel; based on the candidate grayscale value, a grayscale image of the image to be compressed is generated.
  • the determining unit may be specifically configured to determine the position of the pixel in the image to be compressed; and determine the pixel type of the pixel based on the position of the pixel.
  • the grayscale calculation strategy includes a first grayscale calculation strategy and a second grayscale calculation strategy; the determination unit can be specifically used to obtain the pixel type of the pixel in the image to be compressed; if the pixel type is an edge pixel type , then the first grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel according to the channel value of the pixel; if the pixel type is not an edge pixel type, the second grayscale calculation strategy is used according to the channel value of the pixel.
  • Candidate gray value of pixel is a first grayscale calculation strategy and a second grayscale calculation strategy; the determination unit can be specifically used to obtain the pixel type of the pixel in the image to be compressed; if the pixel type is an edge pixel type , then the first grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel according to the channel value of the pixel; if the pixel type is not an edge pixel type, the second grayscale calculation strategy is used according to the channel value of the pixel.
  • the determination unit may be configured to calculate the channel value of the pixel using a first grayscale calculation strategy to obtain a first calculated channel value; and determine candidates for the pixel based on the first calculated channel value. grayscale value.
  • the determination unit may be configured to calculate the channel value of the pixel using a second grayscale calculation strategy to obtain a second calculated channel value; and determine the candidate for the pixel based on the second calculated channel value. grayscale value.
  • the determining unit may be configured to determine a target pixel in the grayscale image whose grayscale value is the target grayscale value based on the grayscale value of the pixel in the grayscale image; and determine the target pixel based on the target pixel.
  • the object boundaries of the object in the image to be compressed.
  • the determining unit may be used to obtain the coordinates of the grayscale image in the target coordinate system; and, based on the grayscale values of the pixels in the grayscale image, extract candidates whose grayscale values under the coordinates are the target grayscale values.
  • the determination unit may be configured to determine target coordinates corresponding to a target number of candidate pixel points from the coordinates based on the number of candidate pixel points; based on the target coordinates, extract from the candidate pixel points that satisfy the preset number The ratio of the target pixels to obtain the target pixels whose grayscale value is the target grayscale value in the grayscale image.
  • the determining unit may be configured to determine the regional feature value of the pixel in the first image feature region according to the channel value of the pixel in the first image feature region; according to the channel value of the pixel in the first image feature region; The target channel value and the regional feature value determine the target pixel value of the pixel point; based on the target pixel value, a second image feature region that matches the target object is extracted from the first image feature region.
  • the determining unit may be configured to fuse candidate channel values among the channel values of pixels in the feature area of the first image to obtain a fused channel value; and determine the first image based on the fused channel value. Regional feature values of pixels in the feature area.
  • the candidate channel value includes a first candidate channel value and a second candidate channel value; the determining unit may be specifically configured to use a first fusion function to perform fusion processing on the first candidate channel value and the second candidate channel value, Obtain the first initial fused channel value; use the second fusion function to fuse the first candidate channel value and the second candidate channel value to obtain the second initial fused channel value; use the third fusion function to fuse the first initial fused channel value The channel value and the second initial post-fusion channel value are fused to obtain the post-fusion channel value.
  • the target pixel value includes a first target pixel value and a second target pixel value; the determination unit can be specifically used if the target channel value of the pixel point in the first image feature area is less than the channel value threshold, and the regional characteristics When the value is less than the first feature value threshold, the target pixel value of the pixel is determined to be the first target pixel value; if the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the regional feature value is greater than or equal to the first When the feature value threshold is used, the target pixel value of the pixel point is determined to be the second target pixel value.
  • the target pixel value includes a first target pixel value and a second target pixel value; the determining unit may be used to determine if the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, and When the regional feature value is less than the second feature value threshold, the target pixel value of the pixel is determined to be the first target pixel value; if the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, and the regional feature value is greater than Or when equal to the second feature value threshold, the target pixel value of the pixel point is determined to be the second target pixel value.
  • the generation unit may be used to obtain the initial coordinates of the image feature area in the target coordinate system. Punctuation points; according to the initial coordinate points, merge the compressed image areas corresponding to the image feature areas to obtain the merged image; determine the compressed image based on the merged image.
  • an embodiment of the present application also provides a computer device, including a memory and a processor; the memory stores a computer program, and the processor is used to run the computer program in the memory to execute any image compression method provided in the embodiment of the present application.
  • embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program is suitable for loading by the processor to execute any image compression method provided by the embodiments of the present application.
  • embodiments of the present application also provide a computer program product, including a computer program.
  • a computer program product including a computer program.
  • any image compression method provided by the embodiments of the present application is implemented.
  • Embodiments of the present application can obtain an image to be compressed, which includes a target object; determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of pixels in the image to be compressed; and obtain each image feature.
  • the compression parameters corresponding to the area, and according to the compression parameters corresponding to each image feature area, each image feature area is compressed separately to obtain the compressed image area; according to the compressed image area, a compressed image is generated; due to the implementation of this application For example, based on the channel values of pixels in the image to be compressed, multiple image feature areas in the image to be compressed that match the target object can be determined, and the compression parameters corresponding to the image feature areas can be used to compress the image feature areas to retain the image features. Key information in the area, thereby improving the clarity of the compressed image.
  • Figure 1 is a schematic diagram of a scene of an image compression method provided by an embodiment of the present application.
  • Figure 2 is a schematic flowchart of an image compression method provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of determining multiple image feature areas matching the target object in the image to be compressed based on the channel values of the pixels in the image to be compressed, provided by an embodiment of the present application;
  • Figure 4 is a schematic diagram of performing boundary recognition on a target object based on the channel values of pixels in the image to be compressed to determine the first image feature area from the image to be compressed, provided by an embodiment of the present application;
  • Figure 5 is a schematic diagram of a grayscale image provided by an embodiment of the present application.
  • Figure 6 is a schematic diagram of a binary image provided by an embodiment of the present application.
  • Figure 7 is a schematic structural diagram of an image compression device provided by an embodiment of the present application.
  • Figure 8 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • Embodiments of the present application provide an image compression method, device, computer equipment, and computer-readable storage medium.
  • the image compression device can be integrated in a computer device, and the computer device can be a server, a terminal or other equipment.
  • the server can be an independent physical server, or a server cluster or server composed of multiple physical servers. or distributed system, and can also provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and network acceleration services (Content Delivery Network, CDN) , as well as cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
  • the terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smart watch, etc., but is not limited to this.
  • the terminal and the server can be connected directly or indirectly through wired or wireless communication methods, which is not limited in this application.
  • the computer device obtains an image to be compressed, and the image to be compressed includes the target object; according to the channel values of the pixels in the image to be compressed, determine the Multiple image feature areas matched by the target object; obtain the compression parameters corresponding to each image feature area, and perform compression processing on each image feature area according to the compression parameters corresponding to each image feature area to obtain the compressed image area; Generate a compressed image based on the compressed image area.
  • the image to be compressed may refer to any image including the target object.
  • the target object includes at least one of people, natural scenery, and objects.
  • the image feature area may refer to an area in the image to be compressed that is associated with the target object.
  • the compression parameter can be the compression rate or the information entropy of the image feature area.
  • the image compression device can be integrated in a computer device.
  • the computer device can be a server or a terminal.
  • the terminal can include a tablet computer, a notebook computer, etc. , and devices such as personal computers (PC, Personal Computer), wearable devices, virtual reality devices or other smart devices that can obtain data.
  • PC Personal Computer
  • wearable devices virtual reality devices or other smart devices that can obtain data.
  • the image to be compressed includes the target object.
  • S102 Determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of the pixels in the image to be compressed.
  • Embodiments of the present application can obtain an image to be compressed, which includes a target object; determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of pixels in the image to be compressed; and obtain each image feature.
  • the compression parameters corresponding to the area, and according to the compression parameters corresponding to each image feature area, each image feature area is compressed separately to obtain the compressed image area; according to the compressed image area, a compressed image is generated; due to the implementation of this application For example, based on the channel values of pixels in the image to be compressed, multiple image feature areas in the image to be compressed that match the target object can be determined, and the compression parameters corresponding to the image feature areas can be used to compress the image feature areas to retain the image features. Key information in the area, thereby improving the clarity of the compressed image.
  • the image compression device is specifically integrated into a computer device, and the computer device is a server or a terminal.
  • Step S101 to Step S104 the specific process of the image compression method is as follows: Step S101 to Step S104:
  • the image to be compressed includes the target object.
  • the embodiment of this application takes the image to be compressed as a portrait image as an example for explanation. narrate.
  • the portrait image may include at least one portrait.
  • the image to be compressed may be stored in a database of the computer device. Based on this, the embodiment of the present application may extract the image to be compressed from the database.
  • multiple candidate images may be stored in the database, and the computer device may obtain the image to be compressed from the candidate images in response to a selection operation on the candidate images.
  • the candidate image may be displayed on a corresponding display screen of the computer device.
  • S102 Determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of the pixels in the image to be compressed.
  • the channel values of the pixels in the image to be compressed may include R value, G value and B value.
  • the channel values of the pixels in the image to be compressed may include R value, G value, B value and A value.
  • the format of the image to be compressed is not limited to the RGB format and the RGBA format, and may also be a YUV format, etc.
  • the embodiment of the present application can obtain the image data (Image Data) of the image to be compressed.
  • the image data is a one-dimensional array.
  • the image data represents the data of each pixel with the values of four channels: R value, G value, B value and A value.
  • the size of the image data of the image to be compressed is width*height*4, where width refers to the width of the image to be compressed and height refers to the height of the image to be compressed.
  • the image data corresponding to the pixels in the image to be compressed in the embodiment of the present application are stored sequentially from left to right and from top to next.
  • the image data of the image to be compressed can be obtained by extracting data from the image to be compressed through an image processing application, such as Canvas.
  • an image processing application such as Canvas.
  • the embodiment of the present application can extract the image data of the image to be compressed through the image data interface of Canvas.
  • the embodiment of the present application may have multiple image feature areas.
  • the embodiment of the present application takes three image feature areas as an example for explanation.
  • the plurality of image feature areas include a first image feature area, a second image feature area, and a third image feature area.
  • the embodiment of the present application determines multiple image feature areas that match the target object in the image to be compressed based on the channel values of the pixels in the image to be compressed, as shown in step A1 to step A3:
  • A1 Perform boundary recognition on the target object according to the channel values of the pixels in the image to be compressed, so as to determine the first image feature area from the image to be compressed.
  • the embodiment of the present application performs boundary identification on the target object based on the channel values of the pixels in the image to be compressed, and the method of determining the first image feature area from the image to be compressed can be as follows: step a11 to step a13:
  • the embodiment of the present application can convert the image to be compressed into a grayscale image based on the channel values of the pixels in the image to be compressed. Specifically, the embodiment of the present application determines the grayscale image of the image to be compressed based on the channel value of the pixel in the image to be compressed by: determining the pixel type of the pixel in the image to be compressed; determining the pixel based on the pixel type. The corresponding grayscale calculation strategy; according to the channel value of the pixel, use the grayscale calculation strategy to calculate the candidate grayscale value of the pixel; based on the candidate grayscale value, generate a grayscale image of the image to be compressed.
  • the pixel type may include edge pixel type and non-edge pixel type.
  • the edge pixel type may refer to the pixel type of the pixels located at the edge of the image to be compressed; the non-edge pixel type may refer to the pixel type of the pixels not located at the edge of the image to be compressed.
  • this situation can be said to be that the pixel is not at the edge of the image to be compressed; when the pixel does not have adjacent pixels at at least one of the four upper, lower, left, and right positions.
  • this situation can be said to be that the pixel is at the edge of the image to be compressed.
  • the grayscale calculation strategy may refer to a strategy for converting the image to be compressed into a grayscale image.
  • the method of determining the pixel type of the pixels in the image to be compressed may be: determining The position of the pixel in the image; determine the pixel type of the pixel based on the position of the pixel.
  • the embodiment of the present application can obtain the target coordinate system of the pixel point in the image to be compressed; based on the target coordinate system, determine the coordinate point of each pixel point in the image to be compressed, so as to determine the position of the pixel point in the image to be compressed based on the coordinate point .
  • the pixel type of the pixel is determined to be the edge type; if the position of the pixel is not the edge position of the image to be compressed, then the pixel type of the pixel is determined not to be the edge. type.
  • the grayscale calculation strategy includes a first grayscale calculation strategy and a second grayscale calculation strategy. Based on this, the grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel according to the channel value of the pixel, Including: obtaining the pixel type of the pixel in the image to be compressed; if the pixel type is an edge pixel type, then using the first grayscale calculation strategy to calculate the candidate grayscale value of the pixel according to the channel value of the pixel; if the pixel type is not For edge pixel types, the second grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel based on the channel value of the pixel.
  • the method of obtaining the pixel type of the pixels in the image to be compressed may be: using a pixel type recognition neural network model to identify the type of pixels in the image to be compressed, and obtaining the pixel type of the pixels in the image to be compressed.
  • the pixel type recognition neural network model can be a convolutional neural network model or a self-attention neural network model.
  • the method of obtaining the pixel type of the pixel in the image to be compressed may be: obtaining the pixel value of the pixel in the image to be compressed; and determining the pixel type of the pixel in the image to be compressed based on the size of the pixel value.
  • the method of determining the pixel type of the pixel in the image to be compressed according to the size of the pixel value can be: determining the preset pixel value range in which the size of the pixel value lies; and searching for the corresponding preset pixel value range according to the preset pixel value range.
  • the preset pixel type use the preset pixel type as the pixel type of the pixels in the image to be compressed.
  • the method of using the first grayscale calculation strategy to calculate the candidate grayscale value of the pixel based on the channel value of the pixel may be: using the first grayscale calculation strategy to calculate the channel value of the pixel, Obtain the first calculated channel value; determine the candidate grayscale value of the pixel according to the first calculated channel value.
  • input can refer to the image data of the image to be compressed;
  • p can refer to the sorting of the p-th pixel point in the image data;
  • p1 can refer to the sorting of the R channel value of the p-th pixel point in the image data, in In the embodiment of the present application, p1 may be equal to p;
  • p3 may refer to the p-th pixel in the image data.
  • the sorting of B channel values of pixels, p3 p1+2;
  • F1 (input, p) can refer to the candidate gray value of the p-th pixel calculated through the first gray calculation strategy; where p is integer.
  • the embodiment of the present application can calculate the candidate gray value of the pixel.
  • the method of using the second grayscale calculation strategy to calculate the candidate grayscale value of the pixel based on the channel value of the pixel may be: using the second grayscale calculation strategy to calculate the channel value of the pixel, Obtain the second calculated channel value; determine the candidate grayscale value of the pixel according to the second calculated channel value.
  • the second grayscale calculation strategy can be found in formula (2), as follows:
  • F2 may refer to the candidate gray value of the pixel calculated through the second gray calculation strategy;
  • w may Indicates the width of the image to be compressed, that is, the number of pixels in a row of the image to be compressed is w.
  • the width of the pixels in a row of the image to be compressed in the image data is w*4;
  • p can be Refers to the sorting of the p-th pixel in the image data;
  • pw can refer to the sorting of the p-th pixel at the same position in the previous row;
  • p+w can refer to the p-th pixel at the same position in the next row.
  • the sorting of pixels; p-1 can refer to the sorting of pixels to the left of the p-th pixel;
  • p+1 can refer to the sorting of pixels to the right of the p-th pixel.
  • the method of generating the grayscale image of the image to be compressed based on the candidate grayscale value may be: obtaining a preset grayscale threshold; determining the grayscale value based on the preset grayscale threshold and the candidate grayscale value; Based on the grayscale value, a grayscale image of the image to be compressed is generated.
  • the grayscale value includes a first grayscale value and a second grayscale value.
  • the first grayscale value may be 255 and the second grayscale value may be 0; the preset grayscale threshold may be 30.
  • the candidate gray value of the pixel is determined as the first gray value; if the candidate gray value is less than the preset gray threshold, then the candidate gray value of the pixel is determined as the first gray value.
  • the candidate gray value is determined as the second gray value.
  • the grayscale calculation strategy may also include a Sobel edge detection operator and a Canny edge detection operator.
  • the method of identifying the object boundary of the target object based on the gray value of the pixel in the gray image may be: based on the gray value of the pixel in the gray image, determine that the gray value in the gray image is the target gray.
  • the target gray value may be 255, that is, the target pixel whose gray value is the target gray value is a white pixel.
  • the object boundary of the target object is determined based on the white pixel.
  • the method of determining the target pixel whose gray value is the target gray value in the gray image may be: obtaining the gray value of the gray image in the target coordinate system The coordinates of The gray value of the target pixel.
  • the embodiment of the present application can establish a target coordinate system for grayscale images.
  • Each pixel in the grayscale image has a corresponding coordinate point in the target coordinate system.
  • the upper left corner of the grayscale image is the coordinate origin of the target coordinate system, the x-axis to the right is the positive direction, and the y-axis is downward to the positive direction.
  • the target coordinate system can be a plane rectangular coordinate system, and the target coordinate system can include the x-axis and the y-axis.
  • the candidate pixel points may refer to white pixel points.
  • the way to determine the target pixels in the grayscale image whose grayscale value is the target grayscale value may be: based on the number of candidate pixels, determine the target number from the coordinates The target coordinates corresponding to the candidate pixel points; according to the target coordinates, target pixel points that meet the preset number ratio are extracted from the candidate pixel points to obtain the target pixel points whose grayscale value is the target grayscale value in the grayscale image.
  • the target coordinate may be the coordinate corresponding to the most white pixel points among all coordinates.
  • the target coordinate is the coordinate with the most white pixels in the x-axis.
  • the target coordinate is the coordinate with the most white pixels in the y-axis.
  • the preset quantity ratio may refer to a ratio of five-sixths of the total number of white pixels.
  • the preset quantity ratio refers to a ratio of five-sixths of the total number of white pixels corresponding to all coordinates of the x-axis.
  • proportion; for the y-axis, the preset quantity proportion refers to the proportion that accounts for five-sixths of the total number of white pixels corresponding to all coordinates of the y-axis.
  • the embodiment of this application starts from the target coordinate and stops when the number of white pixels accounts for five-sixths of the total number of white pixels corresponding to all coordinates on the x-axis.
  • the third point can be determined.
  • An image feature area is one or more coordinate ranges on the x-axis.
  • For the y-axis start taking points from the target coordinates and stop when the number of white pixels accounts for five-sixths of the total number of white pixels corresponding to all coordinates on the y-axis. At this time, it can be determined that the first image feature area is on the y-axis.
  • the object boundary is constructed.
  • the object boundary is shown as the white pixels in the grayscale image in Figure 5.
  • the embodiment of the present application extracts and processes the area inside the object boundary based on the image to be compressed, that is, the first image feature area can be obtained.
  • A2 Perform feature recognition on the target object based on the channel values of the pixels in the first image feature area to extract the second image feature area from the first image feature area.
  • the target object is characterized according to the channel value of the pixel point in the first image feature area
  • the method of extracting the second image feature area from the first image feature area may be: according to the first image feature The channel value of the pixel in the region determines the regional feature value of the pixel in the first image feature region; determines the target pixel value of the pixel according to the target channel value and regional feature value of the pixel in the first image feature region; according to the target The pixel value is used to extract a second image feature area that matches the target object from the first image feature area.
  • the regional feature value may be a value used to determine whether the pixel belongs to the second image feature region.
  • the embodiment of the present application needs to convert the format of the first image feature area. After the first image feature area is converted into RGB format, the first image feature area in RGB format is converted into YCrCb format.
  • the embodiment of this application obtains a white background image.
  • the format of the white background image is RGB format.
  • the R channel value bgR of the white background image is 255
  • the G channel value bgG is 255
  • the B channel value bgB is 255.
  • Divide the A channel value of the first image feature area in RGBA format by 255 to convert the A channel of the first image feature area in RGBA format into a value between 0 and 1 to obtain the first converted channel value sourceA.
  • the R channel value of the first image feature area in RGBA format is recorded as sourceR
  • the G channel value of the first image feature area in RGBA format is recorded as sourceG
  • the B channel value of the first image feature area in RGBA format is recorded as sourceR.
  • the value is recorded as sourceB.
  • targetR may refer to the R channel value in the first image feature area in RGB format
  • targetG may refer to the G channel value in the first image feature area in RGB format
  • targetB may refer to the first image in RGB format B channel value in the feature area.
  • Y may refer to the Y channel value in the first image feature area in YCbCr format
  • Cb may refer to the Cb channel value in the first image feature area in YCbCr format
  • Cr may refer to the first image feature area in YCbCr format Cr channel value in .
  • the method of determining the regional feature value of the pixel point in the first image feature area may be: converting the pixel point in the first image feature area The candidate channel values among the channel values are fused to obtain the fused channel value; based on the fused channel value, the regional feature value of the pixel point in the first image feature area is determined.
  • the embodiment of the present application can perform the fusion process based on the candidate channel values among the channel values of the pixels in the first image feature area in the YCbCr format.
  • Candidate channel values may include Cb channel values and Cr channel values.
  • the candidate channel values include a first candidate channel value and a second candidate channel value. Based on this, the embodiment of the present application fuses the candidate channel values among the channel values of the pixels in the first image feature area.
  • the method of obtaining the fused channel value can be: using the first fusion function to fuse the first candidate channel value and the second candidate channel value to obtain the first initial fused channel value; using the second fusion function to fuse the first candidate channel value The channel value and the second candidate channel value are fused to obtain the second initial fused channel value; the third fusion function is used to fuse the first initial fused channel value and the second initial fused channel value to obtain the fused channel value.
  • the first candidate channel value is the Cb channel value
  • the second candidate channel value is the Cr channel value
  • x1 may refer to the first initial fused channel value.
  • y1 may refer to the second initial post-fusion channel value.
  • val may refer to the post-fusion channel value; in some application embodiments, the post-fusion channel value may be used as the regional feature value of the pixel point in the first image feature region.
  • the regional characteristics of the pixels in the first image feature area are determined based on the fused channel values.
  • the value can be obtained by obtaining a mapping function; performing mapping processing on the fused channel values according to the mapping function to obtain regional feature values of pixels in the first image feature region.
  • the target pixel value includes a first target pixel value and a second target pixel value; the method of determining the target pixel value of the pixel is based on the target channel value and the regional feature value of the pixel in the first image feature area. It can be: if the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the regional feature value is less than the first feature value threshold, determine the target pixel value of the pixel to be the first target pixel value; if the first When the target channel value of the pixel in the image feature area is less than the channel value threshold, and the area feature value is greater than or equal to the first feature value threshold, the target pixel value of the pixel is determined to be the second target pixel value.
  • the target channel value may refer to the y channel value of the pixel in the first image feature area in YCbCr format.
  • the channel value threshold can be 100.
  • the first feature value threshold may be 700.
  • the first target pixel value may be 255.
  • the second target pixel value is 0.
  • the first image feature area determined in the embodiment of the present application can be the area where the portrait is in the image to be compressed, and the second image feature area can be the face area in the portrait. , human eye area, human ear area; etc.
  • the embodiment of this application is explained by taking the second image feature area as a human face area as an example.
  • the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the regional feature value is less than the first feature value threshold, it indicates that the pixel is a pixel falling in the elliptical area, that is, the pixel is For pixels falling in the face area, based on this, the target pixel value of the pixel is determined to be 255. If the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the area feature value is greater than or equal to the first feature value threshold, it means that the pixel is not a pixel falling in the elliptical area, that is, the pixel The point is not a pixel falling in the face area. Based on this, the target pixel value of the pixel is determined to be 0.
  • the target pixel value includes a first target pixel value and a second target pixel value; the method of determining the target pixel value of the pixel is based on the target channel value and the regional feature value of the pixel in the first image feature area.
  • the second feature value threshold may be 850. If the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, and the area feature value is less than the second feature value threshold, it indicates that the pixel is a pixel falling in the elliptical area. Based on this, determine The target pixel value of the pixel is 255. If the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, and the regional feature value is greater than or equal to the second feature value threshold, it indicates that the pixel is not a pixel falling in the elliptical area, based on Therefore, the target pixel value of the pixel is determined to be 0.
  • the embodiment of the present application can convert the first image feature area into a binary image. That is, the embodiment of the present application can convert the first image feature area into a binary image according to the target pixel value.
  • the binary image is shown in Figure 6. That is, the method of extracting the second image feature area that matches the target object from the first image feature area according to the target pixel value in the embodiment of the present application may be: converting the first image feature area into a binary value according to the target pixel value Image; extract the second image feature area matching the target object from the binary image.
  • the embodiment of the present application extracts the second image feature area matching the target object from the binary image by: based on the binary image, using the upper left corner vertex of the binary image as the coordinate origin to construct a candidate rectangular coordinate system ; Obtain the candidate coordinates of the binary image in the candidate rectangular coordinate system; according to the target pixel value of the pixel point in the binary image, extract the number of pixel points whose target pixel value is the first target pixel value under the candidate coordinates; according to the first target The number of pixel points corresponding to the pixel value determines the characteristic pixel points in the binary image; based on the characteristic pixel points, a second image characteristic area that matches the target object is constructed.
  • the characteristic pixel points may refer to pixel points that construct the characteristic area of the second image.
  • the candidate coordinates of and the candidate coordinates when y n, where n is a natural number.
  • the pixel whose target pixel value is the first target pixel value can be a white pixel.
  • the embodiment of the present application extracts the target pixel value at the candidate coordinates according to the target pixel value of the pixel in the binary image.
  • the embodiment of the present application determines the feature pixels in the binary image according to the number of pixels corresponding to the first target pixel value.
  • the point method may be: according to the number of pixel points corresponding to the first target pixel value, determine the reference coordinates corresponding to a preset number of pixel points from the candidate coordinates; according to the reference coordinates, determine the reference coordinates corresponding to the pixel points corresponding to the first target pixel value from the candidate coordinates. Extract feature pixels from points.
  • the embodiment of the present application determines the reference coordinates corresponding to the preset number of pixels from the candidate coordinates according to the number of pixels corresponding to the first target pixel value.
  • the reference coordinate is the x-axis.
  • the first and last candidate coordinates whose number of white pixel points is greater than 10 are used to determine the coordinate range of the second image feature area on the x-axis.
  • the reference coordinates are the first and last two candidate coordinates with a number of white pixels greater than 10 on the y-axis, from which the coordinate range of the second image feature area on the y-axis can be determined.
  • the embodiment of the present application determines the position of the characteristic pixel point in the binary image based on the coordinate range of the second image feature area on the x-axis and the coordinate range of the second image feature area on the y-axis.
  • the method of extracting the feature area of the second image can also be a method of combining the Cr component of the YCrCb color space and the Otsu method threshold segmentation method, which can be based on the YCrCb color space C, Cb range screening method, the HSV color space H Scope screening method; etc.
  • A3 According to the first image feature area, determine the third image feature area from the image to be compressed.
  • the third image feature area does not contain the target object.
  • the remaining part in the image to be compressed is the initial third image feature area. Since after the first image feature area is extracted from the image to be compressed, there are some areas in the initial third image feature area where pixels do not exist. Based on this, the example of this application can fill the area where pixels do not exist with transparent pixels. In this way, the third image feature area can be obtained.
  • embodiments of the present application can also use existing relevant neural network models to identify multiple image feature areas in the image to be compressed that match the target object based on the channel values of the pixels in the image to be compressed.
  • the neural network model can be an object boundary recognition model.
  • the neural network model can be a CNN model, or a self-attention neural network model; and so on.
  • the embodiments of the present application can extract the first image feature areas corresponding to the multiple portraits through the above-mentioned steps a11 to a13; and then , for the first image feature area, the second image feature area corresponding to each portrait is extracted from the first image feature area in the above-mentioned step A2.
  • the embodiments of the present application can identify different portraits through the portrait recognition neural network model, and then perform feature extraction on the different portraits to obtain each portrait.
  • the corresponding first image feature area; the embodiment of the present application can perform face recognition in the first image feature area corresponding to each portrait, so as to identify the third image feature area corresponding to each portrait from the first image feature area corresponding to each portrait. 2. Image feature areas.
  • the embodiments of the present application can identify the portrait through the portrait recognition neural network model and extract the first image feature area corresponding to the portrait; through the object recognition neural network model , identify the object, and extract the first image feature area of the portrait object; then, the first image feature area corresponding to the portrait can be extracted to the second feature area in the above-mentioned step A2.
  • the application embodiment can use the above The corresponding first image feature area is extracted in the above-mentioned step a11 to step a13, and the first image feature area is the characteristic area of the portrait and the object; then, the corresponding first image feature area is extracted from the first image feature area in the above-mentioned step A2. the second characteristic area.
  • the compression parameter may be a compression ratio.
  • Each image feature area has a corresponding compression parameter.
  • the embodiment of the present application can separately compress each image feature area based on the compression parameter corresponding to each image feature area, and obtain a compressed image area corresponding to each image feature area.
  • the embodiment of the present application can determine the importance of each image feature area, and sort the image feature areas according to the importance: the second image feature area is more important than the first image feature area, and the first image feature area is more important than the first image feature area. Three image feature areas are important. Based on this, the embodiment of the present application can use different compression rates to compress each image feature area to different degrees according to the degree of importance.
  • the compression rate of the second image feature area in the embodiment of the present application is greater than the compression rate of the first image feature area, and the compression rate of the first image feature area is greater than the compression rate of the third image feature area.
  • the compression rate of the second image feature region may be greater than 0.8, and the compression rate of the first image feature region and the compression rate of the third image feature region may both be greater than 0.6.
  • the compression rate of the second image feature region may be 0.8; the compression rate of the first image feature region may be 0.6; and the compression rate of the third image feature region may be 0.5.
  • the embodiment of this application can use the image compression interface in Canvas, such as the to Blob API, to compress each image feature area according to the compression parameters corresponding to each image feature area, and obtain the compressed image area.
  • Canvas such as the to Blob API
  • the method of generating a compressed image based on the compressed image area may be: obtaining the initial coordinate points of the image feature area in the target coordinate system; and merging the compressed image areas corresponding to the image feature area based on the initial coordinate points. , obtain the merged image; determine the compressed image based on the merged image.
  • each pixel point of the image to be compressed has a corresponding initial coordinate point in the target coordinate system. Based on this, when extracting image feature areas, the embodiment of the present application can mark the corresponding initial coordinate points of each image feature area in the image to be compressed. The size of the compressed image area remains unchanged. Based on this, embodiments of the present application can splice the compressed image areas corresponding to the image feature areas based on the initial coordinate points to obtain the merged image.
  • the merged image is the compressed image.
  • the format of the compressed image can be image/jpeg or image/webp.
  • the compressed image in the embodiment of this application can be output through an image conversion interface, where the image conversion interface can be window.URL.create Object URL (blob).
  • the image conversion interface may refer to an interface that converts image data into images.
  • Embodiments of the present application can obtain an image to be compressed, which includes a target object; determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of pixels in the image to be compressed; and obtain each image feature.
  • the compression parameters corresponding to the area, and according to the compression parameters corresponding to each image feature area, each image feature area is compressed separately to obtain the compressed image area; according to the compressed image area, a compressed image is generated; due to the implementation of this application For example, based on the channel values of pixels in the image to be compressed, multiple image feature areas in the image to be compressed that match the target object can be determined, and the compression parameters corresponding to the image feature areas can be used to compress the image feature areas to retain the image features. Key information in the area, thereby improving the clarity of the compressed image.
  • inventions of the present application also provide an image compression device.
  • the image compression device can be integrated in a computer device, such as a server or terminal.
  • the terminal can include a tablet computer, a notebook computer and/or Personal computers, etc.
  • the image compression device may include an acquisition unit 301, a determination unit 302, a compression unit 303 and generation unit 304, as follows:
  • the acquisition unit 301 may be used to acquire an image to be compressed, where the image to be compressed includes a target object.
  • the determination unit 302 may be configured to determine multiple image feature areas in the image to be compressed that match the target object according to the channel values of the pixels in the image to be compressed.
  • the plurality of image feature areas include a first image feature area, a second image feature area, and a third image feature area; the determination unit 302 may be used to determine the target according to the channel values of the pixels in the image to be compressed. Perform boundary recognition on the object to determine the first image feature area from the image to be compressed; perform feature recognition on the target object according to the channel value of the pixel point in the first image feature area to extract the second image feature from the first image feature area area; according to the first image feature area, determine the third image feature area from the image to be compressed, and the third image feature area does not contain the target object.
  • the determining unit 302 may be configured to determine the grayscale image of the image to be compressed based on the channel values of the pixels in the image to be compressed; and identify the target object based on the grayscale values of the pixels in the grayscale image. Object boundary; according to the object boundary, extract the first image feature area that matches the target object from the image to be compressed.
  • the determination unit 302 may be used to determine the pixel type of the pixel in the image to be compressed; determine the grayscale calculation strategy corresponding to the pixel based on the pixel type; and use grayscale calculation based on the channel value of the pixel.
  • the strategy calculates candidate grayscale values of pixels; based on the candidate grayscale values, generates a grayscale image of the image to be compressed.
  • the determining unit 302 may be specifically configured to determine the position of the pixel in the image to be compressed; and determine the pixel type of the pixel based on the position of the pixel.
  • the grayscale calculation strategy includes a first grayscale calculation strategy and a second grayscale calculation strategy; the determination unit 302 can be used to obtain the pixel type of the pixel in the image to be compressed; if the pixel type is an edge pixel type, the first grayscale calculation strategy is used to calculate the candidate grayscale value of the pixel according to the channel value of the pixel; if the pixel type is not an edge pixel type, the second grayscale calculation strategy is used based on the channel value of the pixel. Calculate the candidate gray value of the pixel.
  • the determination unit 302 may be configured to calculate the channel value of the pixel using a first grayscale calculation strategy to obtain a first calculated channel value; determine the pixel's channel value based on the first calculated channel value. Candidate gray value.
  • the determination unit 302 may be configured to use a second grayscale calculation strategy to calculate the channel value of the pixel to obtain the second calculated channel value; determine the pixel's channel value based on the second calculated channel value. Candidate gray value.
  • the determining unit 302 may be configured to determine, based on the gray value of the pixel in the gray image, the target pixel in the gray image whose gray value is the target gray value; based on the target pixel, determine The object boundary of the target object in the image to be compressed.
  • the determining unit 302 may be used to obtain the coordinates of the grayscale image in the target coordinate system; according to the grayscale values of the pixels in the grayscale image, extract the grayscale value under the coordinates to be the target grayscale value.
  • the number of candidate pixels based on the number of candidate pixels, determine the target pixel in the grayscale image whose grayscale value is the target grayscale value.
  • the determining unit 302 may be configured to determine target coordinates corresponding to a target number of candidate pixel points from coordinates based on the number of candidate pixel points; based on the target coordinates, extract candidate pixel points that satisfy a preset The target pixels in the quantitative proportion are used to obtain the target pixels whose grayscale value is the target grayscale value in the grayscale image.
  • the determining unit 302 may be configured to determine the regional feature value of the pixel in the first image feature region according to the channel value of the pixel in the first image feature region; The target channel value and regional feature value are used to determine the target pixel value of the pixel point; based on the target pixel value, a second image feature region that matches the target object is extracted from the first image feature region.
  • the determining unit 302 may be configured to fuse candidate channel values among the channel values of pixels in the first image feature area to obtain a fused channel value; and determine the first fusion channel value based on the fused channel value. Regional feature values of pixels in the image feature area.
  • the candidate channel value includes a first candidate channel value and a second candidate channel value; the determining unit 302 may be configured to use a first fusion function to fuse the first candidate channel value and the second candidate channel value. , obtain the first initial fusion channel value; use the second fusion function to fuse the first candidate channel value and the second candidate channel value to obtain the second initial fusion channel value; use the third fusion function to fuse the first initial fusion
  • the post-fusion channel value and the second initial post-fusion channel value are fused to obtain the post-fusion channel value.
  • the target pixel value includes a first target pixel value and a second target pixel value; the determination unit 302 may be specifically configured to: if the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the area When the feature value is less than the first feature value threshold, the target pixel value of the pixel is determined to be the first target pixel value; if the target channel value of the pixel in the first image feature area is less than the channel value threshold, and the area feature value is greater than or equal to the first When a feature value threshold is reached, the target pixel value of the pixel point is determined to be the second target pixel value.
  • the target pixel value includes a first target pixel value and a second target pixel value; the determination unit 302 may be used to determine if the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, And when the regional feature value is less than the second feature value threshold, the target pixel value of the pixel is determined to be the first target pixel value; if the target channel value of the pixel in the first image feature area is greater than or equal to the channel value threshold, and the regional feature value When it is greater than or equal to the second feature value threshold, the target pixel value of the pixel point is determined to be the second target pixel value.
  • the compression unit 303 can be used to obtain the compression parameters corresponding to each image feature area, and perform compression processing on each image feature area according to the compression parameters corresponding to each image feature area to obtain a compressed image area.
  • the generating unit 304 may be configured to generate a compressed image according to the compressed image area.
  • the generation unit 304 may be used to obtain the initial coordinate points of the image feature area in the target coordinate system; and merge the compressed image areas corresponding to the image feature area according to the initial coordinate points to obtain the merged image. ; Determine the compressed image based on the merged image.
  • the acquisition unit 301 of the embodiment of the present application can be used to acquire an image to be compressed, and the image to be compressed includes the target object;
  • the determination unit 302 can be used to determine the pixels in the image to be compressed according to the channel values of the pixels in the image to be compressed. Multiple image feature areas that match the target object;
  • the compression unit 303 can be used to obtain the compression parameters corresponding to each image feature area, and perform compression processing on each image feature area according to the compression parameters corresponding to each image feature area.
  • the generation unit 304 can be used to generate a compressed image according to the compressed image area; because the embodiment of the present application can determine the target object in the image to be compressed based on the channel value of the pixel in the image to be compressed Multiple image feature areas, and use compression parameters corresponding to the image feature areas to compress the image feature areas to retain key information in the image feature areas, thereby improving the clarity of the compressed image.
  • An embodiment of the present application also provides a computer device, as shown in Figure 8, which shows a schematic structural diagram of the computer device involved in the embodiment of the present application. Specifically:
  • the computer device may include components such as a processor 401 of one or more processing cores, a memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404.
  • a processor 401 of one or more processing cores a memory 402 of one or more computer-readable storage media
  • a power supply 403 a power supply 403
  • an input unit 404 an input unit 404.
  • the processor 401 is the control center of the computer equipment, using various interfaces and lines to connect various parts of the entire computer equipment, by running or executing software programs and/or modules stored in the memory 402, and calling software programs stored in the memory 402. Data, perform various functions of computer equipment and process data.
  • the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, where the application processor mainly processes operating systems, user interfaces, computer programs, etc. , the modem processor mainly handles wireless communications. It can be understood that the above modem processor may not be integrated into the processor 401.
  • the memory 402 can be used to store software programs and modules.
  • the processor 401 executes the software programs stored in the memory 402.
  • Software programs and modules to perform various functional applications and data processing.
  • the memory 402 may mainly include a program storage area and a data storage area, where the program storage area may store an operating system, a computer program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the storage data area may store a program based on Data created by the use of computer equipment, etc.
  • memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402 .
  • the computer equipment also includes a power supply 403 that supplies power to various components.
  • the power supply 403 can be logically connected to the processor 401 through a power management system, so that functions such as charging, discharging, and power consumption management can be implemented through the power management system.
  • the power supply 403 may also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
  • the computer device may also include an input unit 404 operable to receive input communications of numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and functional controls.
  • an input unit 404 operable to receive input communications of numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and functional controls.
  • the computer device may also include a display unit and the like, which will not be described again here.
  • the processor 401 in the computer device will load the executable files corresponding to the processes of one or more computer programs into the memory 402 according to the following instructions, and the processor 401 will run the executable files stored in the computer program.
  • the computer program in memory 402 implements various functions, as follows:
  • the image to be compressed which includes the target object; determine multiple image feature areas in the image to be compressed that match the target object based on the channel values of the pixels in the image to be compressed; obtain the compression parameters corresponding to each image feature area , and according to the compression parameters corresponding to each image feature area, each image feature area is compressed separately to obtain the compressed image area; based on the compressed image area, a compressed image is generated.
  • embodiments of the present application provide a computer-readable storage medium in which a computer program is stored, and the computer program can be loaded by a processor to execute any image compression method provided by embodiments of the present application.
  • the computer-readable storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, etc.
  • a computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
  • the processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the methods provided in the various optional implementations provided by the above embodiments.

Landscapes

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

Abstract

本申请实施例提供一种图像压缩方法、装置、计算机设备及计算机可读存储介质,根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像。本申请实施例可以提高压缩后图像的清晰度。

Description

图像压缩方法、装置、计算机设备及计算机可读存储介质
本申请要求申请日为2022年09月15日、申请号为202211125051.8、发明名称为“图像压缩方法、装置、计算机设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及图像压缩技术领域,具体涉及一种图像压缩方法、装置、计算机设备及计算机可读存储介质。
背景技术
随着图像压缩技术的发展,人们越来越希望压缩后图像仍然具有较高的清晰度。目前对图像进行压缩的方式一般采用对图像进行整体压缩,但是整体压缩的方式容易图像中的关键信息丢失,从而导致压缩后图像变得模糊,不够清晰。
综上,现有存在对图像压缩后,压缩后图像不清晰的问题。
技术问题
现有存在对图像压缩后,压缩后图像不清晰的问题。
技术解决方案
本申请实施例提供一种图像压缩方法、装置、计算机设备及计算机可读存储介质,能够提高压缩后图像的清晰度。
一种图像压缩方法,包括:
获取待压缩图像,待压缩图像中包括目标对象;
根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;
获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;
根据压缩后图像区域,生成压缩后图像。
相应地,本申请实施例提供一种图像压缩装置,包括:
获取单元,可以用于获取待压缩图像,待压缩图像中包括目标对象;
确定单元,可以用于根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;
压缩单元,可以用于获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;
生成单元,可以用于根据压缩后图像区域,生成压缩后图像。
在一些实施例中,多个图像特征区域包括第一图像特征区域、第二图像特征区域和第三图像特征区域;确定单元,具体可以用于根据待压缩图像中像素点的通道值对目标对象进行边界识别,以从待压缩图像中确定第一图像特征区域;根据第一图像特征区域中像素点的通道值对目标对象进行特征识别,以从第一图像特征区域中提取第二图像特征区域;根据第一图像特征区域,从待压缩图像中确定第三图像特征区域,第三图像特征区域不包含目标对象。
在一些实施例中,确定单元,具体可以用于根据待压缩图像中像素点的通道值,确定待压缩图像的灰度图像;根据灰度图像中像素点的灰度值,识别目标对象的对象边界;根据对象边界,从待压缩图像中提取与目标对象匹配的第一图像特征区域。
在一些实施例中,确定单元,具体可以用于确定待压缩图像中像素点的像素类型;根据 像素类型,确定像素点对应的灰度计算策略;根据像素点的通道值,采用灰度计算策略计算像素点的候选灰度值;根据候选灰度值,生成待压缩图像的灰度图像。
在一些实施例中,确定单元,具体可以用于确定待压缩图像中像素点的位置;根据像素点的位置,确定像素点的像素类型。
在一些实施例中,灰度计算策略包括第一灰度计算策略和第二灰度计算策略;确定单元,具体可以用于获取待压缩图像中像素点的像素类型;若像素类型为边缘像素类型,则根据像素点的通道值,采用第一灰度计算策略计算像素点的候选灰度值;若像素类型不为边缘像素类型,则根据像素点的通道值,采用第二灰度计算策略计算像素点的候选灰度值。
在一些实施例中,确定单元,具体可以用于采用第一灰度计算策略对像素点的通道值进行计算,得到第一计算后通道值;根据第一计算后通道值,确定像素点的候选灰度值。
在一些实施例中,确定单元,具体可以用于采用第二灰度计算策略对像素点的通道值进行计算,得到第二计算后通道值;根据第二计算后通道值,确定像素点的候选灰度值。
在一些实施例中,确定单元,具体可以用于根据灰度图像中像素点的灰度值,确定灰度图像中灰度值为目标灰度值的目标像素点;根据目标像素点,确定目标对象在待压缩图像中的对象边界。
在一些实施例中,确定单元,具体可以用于获取灰度图像在目标坐标系下的坐标;根据灰度图像中像素点的灰度值,提取坐标下灰度值为目标灰度值的候选像素点的数量;根据候选像素点的数量,确定灰度图像中灰度值为目标灰度值的目标像素点。
在一些实施例中,确定单元,具体可以用于根据候选像素点的数量,从坐标中确定具有目标数量的候选像素点对应的目标坐标;根据目标坐标,从候选像素点中提取满足预设数量比例的目标像素点,以得到灰度图像中灰度值为目标灰度值的目标像素点。
在一些实施例中,确定单元,具体可以用于根据第一图像特征区域中像素点的通道值,确定第一图像特征区域中像素点的区域特征值;根据第一图像特征区域中像素点的目标通道值和区域特征值,确定像素点的目标像素值;根据目标像素值,从第一图像特征区域中提取与目标对象匹配的第二图像特征区域。
在一些实施例中,确定单元,具体可以用于将第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值;根据融合后通道值,确定第一图像特征区域中像素点的区域特征值。
在一些实施例中,候选通道值包括第一候选通道值和第二候选通道值;确定单元,具体可以用于采用第一融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第一初始融合后通道值;采用第二融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第二初始融合后通道值;采用第三融合函数对第一初始融合后通道值和第二初始融合后通道值进行融合处理,得到融合后通道值。
在一些实施例中,目标像素值包括第一目标像素值和第二目标像素值;确定单元,具体可以用于若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值小于第一特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值大于或等于第一特征值阈值时,确定像素点的目标像素值为第二目标像素值。
在一些实施例中,目标像素值包括第一目标像素值和第二目标像素值;确定单元,具体可以用于若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值小于第二特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值大于或等于第二特征值阈值时,确定像素点的目标像素值为第二目标像素值。
在一些实施例中,生成单元,具体可以用于获取图像特征区域在目标坐标系中的初始坐 标点;根据初始坐标点,对图像特征区域对应的压缩后图像区域进行合并,得到合并后图像;根据合并后图像,确定压缩后图像。
此外,本申请实施例还提供一种计算机设备,包括存储器和处理器;存储器存储有计算机程序,处理器用于运行存储器内的计算机程序,以执行本申请实施例提供的任一种图像压缩方法。
此外,本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质存储有计算机程序,计算机程序适于处理器进行加载,以执行本申请实施例提供的任一种图像压缩方法。
此外,本申请实施例还提供一种计算机程序产品,包括计算机程序,计算机程序被处理器执行时实现本申请实施例所提供的任一种图像压缩方法。
有益效果
本申请实施例可以获取待压缩图像,待压缩图像中包括目标对象;根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像;由于本申请实施例可以基于待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域,并利用图像特征区域对应的压缩参数对图像特征区域进行压缩处理,以保留图像特征区域中的关键信息,从而提高压缩后图像的清晰度。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的图像压缩方法的场景示意图;
图2是本申请实施例提供的图像压缩方法的流程示意一图;
图3是本申请实施例提供的根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域的示意图;
图4是本申请实施例提供的根据待压缩图像中像素点的通道值对目标对象进行边界识别,以从待压缩图像中确定第一图像特征区域的示意图;
图5是本申请实施例提供的灰度图像的示意图;
图6为本申请实施例提供的二值图像的示意图;
图7是本申请实施例提供的图像压缩装置的结构示意图;
图8是本申请实施例提供的计算机设备的结构示意图。
本发明的实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供一种图像压缩方法、装置、计算机设备和计算机可读存储介质。其中,该图像压缩装置可以集成在计算机设备中,该计算机设备可以是服务器,也可以是终端等设备。
其中,服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或 者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、网络加速服务(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。终端可以是智能手机、平板电脑、笔记本电脑、台式计算机、智能音箱、智能手表等,但并不局限于此。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
例如,参见图1,以图像压缩装置集成在计算机设备中为例,计算机设备获取待压缩图像,待压缩图像中包括目标对象;根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像。
其中,待压缩图像可以是指包括目标对象的任意图像。
其中,目标对象包括人物、自然风景、物体中的至少一种。
其中,图像特征区域可以是指待压缩图像中,与目标对象存在关联的区域。
其中,压缩参数可以是压缩率,也可以是图像特征区域的信息熵。
以下分别进行详细说明。需说明的是,以下实施例的描述顺序不作为对实施例优选顺序的限定。
本实施例将从图像压缩装置的角度进行描述,该图像压缩装置具体可以集成在计算机设备中,该计算机设备可以是服务器,也可以是终端等设备;其中,该终端可以包括平板电脑、笔记本电脑、以及个人计算机(PC,Personal Computer)、可穿戴设备、虚拟现实设备或其他可以获取数据的智能设备等设备。
如图2所示,该图像压缩方法的具体流程如步骤S101至步骤S104:
S101、获取待压缩图像。
其中,待压缩图像中包括目标对象。
S102、根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域。
S103、获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域。
S104、根据压缩后图像区域,生成压缩后图像。
本申请实施例可以获取待压缩图像,待压缩图像中包括目标对象;根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像;由于本申请实施例可以基于待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域,并利用图像特征区域对应的压缩参数对图像特征区域进行压缩处理,以保留图像特征区域中的关键信息,从而提高压缩后图像的清晰度。
根据上面实施例所描述的方法,以下将举例作进一步详细说明。
在本实施例中,将以该图像压缩装置具体集成在计算机设备,计算机设备为服务器,也可以为终端。
首先,要说明的是,目前对图像进行压缩的方式一般采用对图像进行整体压缩,但是整体压缩的方式容易图像中的关键信息丢失,从而导致压缩后图像变得模糊,不够清晰。基于此,本申请实施例提供一种图像压缩方法,以压缩后图像的清晰度和压缩的准确度,如图2所示,该图像压缩方法的具体流程如步骤S101至步骤S104:
S101、获取待压缩图像。
其中,待压缩图像中包括目标对象。本申请实施例以待压缩图像为人像图像为例进行阐 述。在本申请实施例中,人像图像中可以包括至少一个人像。
在本申请实施例中,待压缩图像可以存储于计算机设备的数据库中,基于此,本申请实施例可以从数据库中提取到待压缩图像。
在本申请实施例中,数据库中可以存储多张候选图像,计算机设备可以响应于针对候选图像的选择操作,从候选图像中获取到待压缩图像。
其中,候选图像可以显示于计算机设备对应的显示屏幕上。
S102、根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域。
其中,当待压缩图像为RGB图像时,待压缩图像中像素点的通道值可以包括R值、G值和B值。当待压缩图像为RGBA图像时,待压缩图像中像素点的通道值可以包括R值、G值、B值和A值。待压缩图像的格式不限于RGB格式以及RGBA格式,还可以为YUV格式,等等。
本申请实施例以待压缩图像为RGBA图像为例进行阐述。
本申请实施例可以获取待压缩图像的图像数据(Image Data),图像数据为一维数组,图像数据以R值、G值、B值和A值四个通道的值表示每一个像素点的数据。待压缩图像的图像数据的尺寸为width*height*4,其中,width是指待压缩图像宽度,height是指待压缩图像的高度。
其中,本申请实施例待压缩图像中像素点对应的图像数据按从左到右,从上到下一次依次进行存储。
其中,本申请实施例可以通过图像处理应用程序,如Canvas对待压缩图像进行数据提取,得到待压缩图像的图像数据。具体来说,本申请实施例可以通过Canvas的图像数据接口提取到待压缩图像的图像数据。
其中,本申请实施例的图像特征区域可以具有多个,本申请实施例以图像特征区域具有三个为例进行阐述。比如,多个图像特征区域包括第一图像特征区域、第二图像特征区域和第三图像特征区域。
基于上述,如图3所示,本申请实施例根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域的方式可以如步骤A1至步骤A3:
A1、根据待压缩图像中像素点的通道值对目标对象进行边界识别,以从待压缩图像中确定第一图像特征区域。
如图4所示,本申请实施例根据待压缩图像中像素点的通道值对目标对象进行边界识别,以从待压缩图像中确定第一图像特征区域的方式可以如步骤a11至步骤a13:
a11、根据待压缩图像中像素点的通道值,确定待压缩图像的灰度图像。
此处可以理解的是,本申请实施例可以基于待压缩图像中像素点的通道值,将待压缩图像转化为灰度图像。具体来说,本申请实施例根据待压缩图像中像素点的通道值,确定待压缩图像的灰度图像的方式可以为:确定待压缩图像中像素点的像素类型;根据像素类型,确定像素点对应的灰度计算策略;根据像素点的通道值,采用灰度计算策略计算像素点的候选灰度值;根据候选灰度值,生成待压缩图像的灰度图像。
其中,像素类型可以包括边缘像素类型和非边缘像素类型。边缘像素类型可以是指处于待压缩图像边缘位置的像素点的像素类型;非边缘像素类型可以是指不处于待压缩图像边缘位置的像素点的像素类型。当像素点在上下左右四个位置均存在相邻的像素点时,此种情况可以称像素点不处于待压缩图像的边缘位置;当像素点在上下左右四个位置中至少一个位置不存在相邻的像素点时,此种情况可以称像素点处于待压缩图像的边缘位置。
其中,灰度计算策略可以是指将待压缩图像转化为灰度图像的策略。
在一些申请实施例中,确定待压缩图像中像素点的像素类型的方式可以为:确定待压缩 图像中像素点的位置;根据像素点的位置,确定像素点的像素类型。
其中,本申请实施例可以获取待压缩图像中像素点的目标坐标系;基于目标坐标系,确定待压缩图像中每一像素点的坐标点,以基于坐标点确定待压缩图像中像素点的位置。
其中,若像素点的位置为待压缩图像的边缘位置,则确定像素点的像素类型为边缘类型;若像素点的位置不为待压缩图像的边缘位置,则确定像素点的像素类型不为边缘类型。
在一些申请实施例中,灰度计算策略包括第一灰度计算策略和第二灰度计算策略,基于此,根据像素点的通道值,采用灰度计算策略计算像素点的候选灰度值,包括:获取待压缩图像中像素点的像素类型;若像素类型为边缘像素类型,则根据像素点的通道值,采用第一灰度计算策略计算像素点的候选灰度值;若像素类型不为边缘像素类型,则根据像素点的通道值,采用第二灰度计算策略计算像素点的候选灰度值。
在一示例中,此处获取待压缩图像中像素点的像素类型可参见前述“确定待压缩图像中像素点的像素类型”的过程,此处不再赘述。
在一示例中,获取待压缩图像中像素点的像素类型的方式可以为:采用像素类型识别神经网络模型对待压缩图像中像素点进行类型识别,得到待压缩图像中像素点的像素类型。其中,像素类型识别神经网络模型可以为卷积神经网络模型,也可以为自注意力神经网络模型。
在一示例中,获取待压缩图像中像素点的像素类型的方式可以为:获取待压缩图像中像素点的像素值;根据像素值的大小确定待压缩图像中像素点的像素类型。
其中,根据像素值的大小确定待压缩图像中像素点的像素类型的方式可以为:判断像素值的大小所处的预设像素值范围;根据预设像素值范围,查找预设像素值范围对应的预设像素类型;将预设像素类型作为待压缩图像中像素点的像素类型。
基于上述,本申请实施例根据像素点的通道值,采用第一灰度计算策略计算像素点的候选灰度值的方式可以为:采用第一灰度计算策略对像素点的通道值进行计算,得到第一计算后通道值;根据第一计算后通道值,确定像素点的候选灰度值。
具体来说,第一灰度计算策略可以参见公式(1),如下:
F1(input,p)=0.2126*input[p1]+0.7152*input[p2]+0.0722*input[p3]  公式(1)
其中,input可以是指待压缩图像的图像数据;p可以是指第p个像素点在图像数据的排序;p1可以是指在图像数据中,第p个像素点的R通道值的排序,在本申请实施例中,p1可以等于p;p2可以是指在图像数据中,第p个像素点的G通道值的排序,p2=p1+1;p3可以是指在图像数据中,第p个像素点的B通道值的排序,p3=p1+2;F1(input,p)可以是指通过第一灰度计算策略计算所得到的第p个像素点的候选灰度值;其中,p为整数。
基于上述,本申请实施例可以计算得到像素点的候选灰度值。
基于上述,本申请实施例根据像素点的通道值,采用第二灰度计算策略计算像素点的候选灰度值的方式可以为:采用第二灰度计算策略对像素点的通道值进行计算,得到第二计算后通道值;根据第二计算后通道值,确定像素点的候选灰度值。
具体来说,第二灰度计算策略可以参见公式(2),如下:
其中,F2可以是指通过第二灰度计算策略计算所得到的像素点的候选灰度值;w可以 表示待压缩图像的宽度,也即待压缩图像一行像素点的数量为w,此处,需要说明的是待压缩图像在一行像素点在图像数据中所占据的宽度为w*4;p可以是指第个像素点在图像数据的排序;p-w可以是指第p个像素点在上一行的相同位置对应的像素点的排序;p+w可以是指第p个像素点在下一行相同位置对应的像素点的排序;p-1可以是指第p个像素点左边的像素点的排序;p+1可以是指第p个像素点右边的像素点的排序。
在一些申请实施例中,根据候选灰度值,生成待压缩图像的灰度图像的方式可以为:获取预设灰度阈值;根据预设灰度阈值和候选灰度值,确定灰度值;根据灰度值,生成待压缩图像的灰度图像。
其中,灰度值包括第一灰度值和第二灰度值,第一灰度值可以为255,第二灰度值可以为0;预设灰度阈值可以为30。
其中,若候选灰度值大于或等于预设灰度阈值,则将像素点的候选灰度值确定为第一灰度值;若候选灰度值小于预设灰度阈值,则将像素点的候选灰度值确定为第二灰度值。
在一些申请实施例中,灰度计算策略还可以包括索贝尔(sobel)边缘检测算子和坎尼(canny)边缘检测算子。
a12、根据灰度图像中像素点的灰度值,识别目标对象的对象边界。
本申请实施例根据灰度图像中像素点的灰度值,识别目标对象的对象边界的方式可以为:根据灰度图像中像素点的灰度值,确定灰度图像中灰度值为目标灰度值的目标像素点;根据目标像素点,确定目标对象在待压缩图像中的对象边界。
其中,目标灰度值可以为255,也即灰度值为目标灰度值的目标像素点为白色的像素点,本申请实施例基于白色的像素点确定目标对象的对象边界。
在一些申请实施例中,根据灰度图像中像素点的灰度值,确定灰度图像中灰度值为目标灰度值的目标像素点的方式可以为:获取灰度图像在目标坐标系下的坐标;根据灰度图像中像素点的灰度值,提取坐标下灰度值为目标灰度值的候选像素点的数量;根据候选像素点的数量,确定灰度图像中灰度值为目标灰度值的目标像素点。
其中,本申请实施例可以对灰度图像建立目标坐标系。灰度图像中每一像素点在目标坐标系中具有对应的坐标点。灰度图像左上角为目标坐标系的坐标原点,x轴向右为正方向,y轴向下为正方向。
其中,目标坐标系可以为平面直角坐标系,目标坐标系可以包括x轴和y轴,目标坐标系下的坐标可以包括x=n时的坐标和y=n时的坐标,其中,n为自然数。
其中,候选像素点可以是指白色的像素点,基于此,根据灰度图像中像素点的灰度值,提取坐标下灰度值为目标灰度值的候选像素点的数量具体可以是:统计x轴在坐标x=n时所包含白色像素点的数量,获得x轴的坐标和白色像素点的数量之间的分布关系;统计y轴在坐标y=n时所包含白色像素点的数量,获得y轴的坐标和白色像素点的数量之间的分布关系。
在一些申请实施例中,根据候选像素点的数量,确定灰度图像中灰度值为目标灰度值的目标像素点的方式可以为:根据候选像素点的数量,从坐标中确定具有目标数量的候选像素点对应的目标坐标;根据目标坐标,从候选像素点中提取满足预设数量比例的目标像素点,以得到灰度图像中灰度值为目标灰度值的目标像素点。
具体来说,其中,目标坐标可以是在所有坐标中具有最多白色像素点对应的坐标。比如,对于x轴,目标坐标是x轴中具有最多白色像素点的坐标,比如,当x=1时,白色像素点的数量有5个;当x=2时,白色像素点的数量有7个;当x=3时,白色像素点的数量有15个;此处仅为示例,因此未对x轴上每个坐标的白色像素点的数量进行一一示例。其中,对于x 轴来说,在x=3时,白色像素点的数量是最多的,因此,可以将x=3作为目标坐标。
基于上述,对于y轴,目标坐标是y轴中具有最多白色像素点的坐标。
其中,预设数量比例可以是指占白色像素点总数六分之五的比例,对于x轴来说,预设数量比例是指占x轴所有坐标对应的白色像素点总数六分之五的比例;对于y轴来说,预设数量比例是指占y轴所有坐标对应的白色像素点总数六分之五的比例。
具体来说,本申请实施例针对x轴,从目标坐标开始取点,从截至白色像素点的数量占x轴所有坐标对应的白色像素点总数六分之五时停止,此时可以确定第一图像特征区域在x轴上一段或多段坐标范围。针对y轴,从目标坐标开始取点,从截至白色像素点的数量占y轴所有坐标对应的白色像素点总数六分之五时停止,此时可以确定第一图像特征区域在y轴上的一段或多段坐标范围。
基于上述确定出的第一图像特征区域在y轴上的一段或多段坐标范围,以及第一图像特征区域在x轴上一段或多段坐标范围,构建对象边界。
基于上述,对象边界如图5灰度图像中白色像素点所示。
a13、根据对象边界,从待压缩图像中提取与目标对象匹配的第一图像特征区域。
基于上述,本申请实施例基于待压缩图像,将对象边界内部的区域提取处理,即可以得到第一图像特征区域。
A2、根据第一图像特征区域中像素点的通道值对目标对象进行特征识别,以从第一图像特征区域中提取第二图像特征区域。
在本申请实施例中,根据第一图像特征区域中像素点的通道值对目标对象进行特征识别,以从第一图像特征区域中提取第二图像特征区域的方式可以为:根据第一图像特征区域中像素点的通道值,确定第一图像特征区域中像素点的区域特征值;根据第一图像特征区域中像素点的目标通道值和区域特征值,确定像素点的目标像素值;根据目标像素值,从第一图像特征区域中提取与目标对象匹配的第二图像特征区域。
其中,区域特征值可以是用于确定像素点是否属于第二图像特征区域的值。
此处要说明的是,由于第一图像特征区域为RGBA格式,本申请实施例为了提取到第二图像特征区域,本申请实施例需要将第一图像特征区域的格式进行转换,本申请实施例将第一图像特征区域转换为RGB格式后,再将RGB格式的第一图像特征区域转换为YCrCb格式。
首先,本申请实施例获取白色背景图,白色背景图的格式为RGB格式,白色背景图R通道值bgR为255,G通道值bgG为255,B通道值bgB为255。将RGBA格式的第一图像特征区域的A通道值除以255,以将RGBA格式的第一图像特征区域的A通道转化为0-1之间,得到第一转化后通道值sourceA。本申请实施例将RGBA格式的第一图像特征区域的R通道值记为sourceR,将RGBA格式的第一图像特征区域的G通道值记为sourceG,将RGBA格式的第一图像特征区域的B通道值记为sourceB。
其次,本申请实施例将RGBA格式的第一图像特征区域转换为RGB格式可以采用公式(3)、公式(4)和公式(5):
targetR=sourceA*sourceR+(1-sourceA)*bgR   公式(3)
targetG=sourceA*sourceG+(1-sourceA)*bgG   公式(4)
targetB=sourceA*sourceB+(1-sourceA)*bgB   公式(5)
其中,targetR可以是指RGB格式的第一图像特征区域中的R通道值;targetG可以是指RGB格式的第一图像特征区域中的G通道值;targetB可以是指RGB格式的第一图像 特征区域中的B通道值。
然后,本申请实施例将RGB格式的第一图像特征区域转换为YCrCb格式可以采用公式(6)、公式(7)和公式(8):
Y=0.257targetR+0.504targetG+0.098targetB+16   公式(6)
Cb=-0.148targetR-0.291targetG+0.439targetB+128   公式(7)
Cr=0.439targetR-0.368targetG-0.071targetB+128   公式(8)
其中,Y可以是指YCbCr格式的第一图像特征区域中的Y通道值;Cb可以是指YCbCr格式的第一图像特征区域中的Cb通道值;Cr可以是指YCbCr格式的第一图像特征区域中的Cr通道值。
基于上述,在一些申请实施例中,根据第一图像特征区域中像素点的通道值,确定第一图像特征区域中像素点的区域特征值的方式可以为:将第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值;根据融合后通道值,确定第一图像特征区域中像素点的区域特征值。
其中,本申请实施例可以基于YCbCr格式的第一图像特征区域中像素点的通道值中的候选通道值进行融合处理。候选通道值可以包括Cb通道值和Cr通道值。
在一些申请实施例中,候选通道值包括第一候选通道值和第二候选通道值,基于此,本申请实施例将第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值的方式可以为:采用第一融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第一初始融合后通道值;采用第二融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第二初始融合后通道值;采用第三融合函数对第一初始融合后通道值和第二初始融合后通道值进行融合处理,得到融合后通道值。
其中,例如,第一候选通道值为Cb通道值,第二候选通道值为Cr通道值。
基于上述,第一融合函数可以参见公式(9),如下:
其中,x1可以是指第一初始融合后通道值。
基于上述,第二融合函数可以参见公式(10),如下:
其中,y1可以是指第二初始融合后通道值。
基于上述,第三融合函数可以参见公式(11),如下:
val=x1*x1+y1*y1       公式(11)
其中,val可以是指融合后通道值;在一些申请实施例中,可以将融合后通道值作为第一图像特征区域中像素点的区域特征值。
在一些申请实施例中,根据融合后通道值,确定第一图像特征区域中像素点的区域特征 值的方式可以为,获取映射函数;根据映射函数对融合后通道值进行映射处理,得到第一图像特征区域中像素点的区域特征值。
在一些申请实施例中,目标像素值包括第一目标像素值和第二目标像素值;根据第一图像特征区域中像素点的目标通道值和区域特征值,确定像素点的目标像素值的方式可以为:若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值小于第一特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值大于或等于第一特征值阈值时,确定像素点的目标像素值为第二目标像素值。
其中,目标通道值可以是指YCbCr格式的第一图像特征区域中像素点的y通道值。
其中,通道值阈值可以为100。第一特征值阈值可以为700。第一目标像素值可以为255。第二目标像素值为0。
由于本申请实施例的待压缩图像为人像图像,基于此,本申请实施例确定的第一图像特征区域可以人像在待压缩图像中的区域,第二图像特征区域可以为人像中的人脸区域、人眼区域、人耳区域;等等。本申请实施例以第二图像特征区域为人脸区域为例进行阐述。
其中,若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值小于第一特征值阈值时,表明该像素点为落在椭圆区域的像素点,即该像素点为落在人脸区域的像素点,基于此,确定像素点的目标像素值为255。若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值大于或等于第一特征值阈值时,表明该像素点不为落在椭圆区域中的像素点,即该像素点不为落在人脸区域的像素点,基于此,确定像素点的目标像素值为0。
在一些申请实施例中,目标像素值包括第一目标像素值和第二目标像素值;根据第一图像特征区域中像素点的目标通道值和区域特征值,确定像素点的目标像素值的方式可以为:若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值小于第二特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值大于或等于第二特征值阈值时,确定像素点的目标像素值为第二目标像素值。
其中,第二特征值阈值可以为850。若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值小于第二特征值阈值时,表明该像素点为落在椭圆区域中的像素点,基于此,确定像素点的目标像素值为255。若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值大于或等于第二特征值阈值时,表明该像素点不为落在椭圆区域中的像素点,基于此,确定像素点的目标像素值为0。
基于上述,本申请实施例可以将第一图像特征区域转化为二值图像,也即,本申请实施例可以根据目标像素值,将第一图像特征区域转化为二值图像。二值图像如图6所示。也即,本申请实施例根据目标像素值,从第一图像特征区域中提取与目标对象匹配的第二图像特征区域的方式可以为:根据目标像素值,将第一图像特征区域转化为二值图像;从二值图像中提取与目标对象匹配的第二图像特征区域。
具体来说,本申请实施例从二值图像中提取与目标对象匹配的第二图像特征区域的具体可以是:基于二值图像,以二值图像的左上角顶点作为坐标原点构建候选直角坐标系;获取二值图像在候选直角坐标系下的候选坐标;根据二值图像中像素点的目标像素值,提取候选坐标下目标像素值为第一目标像素值的像素点的数量;根据第一目标像素值对应的像素点的数量,确定二值图像中的特征像素点;根据特征像素点,构建与目标对象匹配的第二图像特征区域。
其中,特征像素点可以是指构建第二图像特征区域的像素点。
其中,直角坐标系中x轴向右为正方向,y轴向下为正方向。候选坐标可以包括x=n时 的候选坐标和y=n时的候选坐标,其中,n为自然数。
其中,目标像素值为第一目标像素值的像素点可以是白色的像素点,基于此,本申请实施例根据二值图像中像素点的目标像素值,提取候选坐标下目标像素值为第一目标像素值的像素点的数量可以为:统计x轴在候选坐标x=n时所包含白色像素点的数量,获得x轴的候选坐标和白色像素点的数量之间的分布关系;统计y轴在候选坐标y=n时所包含白色像素点的数量,获得y轴的候选坐标和白色像素点的数量之间的分布关系。
其中,由于人脸的面部区域的连贯性和为了减少噪点对第二图像特征区域提取的影响,本申请实施例根据第一目标像素值对应的像素点的数量,确定二值图像中的特征像素点的方式具体可以是:根据第一目标像素值对应的像素点的数量,从候选坐标中确定具有预设数量的像素点对应的参考坐标;根据参考坐标,从第一目标像素值对应的像素点中提取特征像素点。
基于上述,本申请实施例根据第一目标像素值对应的像素点的数量,从候选坐标中确定具有预设数量的像素点对应的参考坐标具体可以是:针对于x轴,参考坐标是x轴上白色像素点数量大于10的首尾两个候选坐标,由此可以确定第二图像特征区域在x轴上的坐标范围。针对于y轴,参考坐标是y轴上白色像素点数量大于10的首尾两个候选坐标,由此可以确定第二图像特征区域在y轴上的坐标范围。
基于上述,本申请实施例基于第二图像特征区域在x轴上的坐标范围和第二图像特征区域在y轴上的坐标范围,确定特征像素点在二值图像中的位置。
在一些申请实施例中,提取第二图像特征区域的方式还可以为YCrCb颜色空间Cr分量和Otsu法阈值分割法结合的方式,可以为基于YCrCb颜色空间C、Cb范围筛选法,HSV颜色空间H范围筛选法;等等。
A3、根据第一图像特征区域,从待压缩图像中确定第三图像特征区域。
其中,第三图像特征区域不包含目标对象。
在本申请实施例中,本申请实施例可以从待压缩图像中提取出第一图像特征区域后,在待压缩图像中剩余的部分即为初始第三图像特征区域。由于待压缩图像中提取出第一图像特征区域后,初始第三图像特征区域中有一部分区域不存在像素点,基于此,本申请实例可以用透明像素点填充不存在像素点的那部分区域,如此可以得到第三图像特征区域。
除了上述,本申请实施例还可以采用现有相关的神经网络模型对根据待压缩图像中像素点的通道值,识别出待压缩图像中与目标对象匹配的多个图像特征区域。神经网络模型可以为对象边界识别模型,具体来说,神经网络模型可以为CNN模型,还可以为自注意力神经网络模型;等等。
在一些申请实施例中,当待压缩图像中包括多个人像时,本申请实施例可以通过本申请实施例如上述步骤a11至步骤a13的方式提取到多个人像对应的第一图像特征区域;然后,针对第一图像特征区域,采用如上述步骤A2的方式从第一图像特征区域中提取到每一人像对应的第二图像特征区域。
在一些申请实施例中,当待压缩图像中包括多个人像时,本申请实施例可以通过人像识别神经网络模型,识别出不同的人像,然后,对不同的人像进行特征提取,得到每一人像对应的第一图像特征区域;本申请实施例可以在每一人像对应的第一图像特征区域中分别进行人脸识别,以从每一人像对应的第一图像特征区域中每一人像对应的第二图像特征区域。
在一些申请实施例中,当待压缩图像中包括人像和物体时,本申请实施例可以通过人像识别神经网络模型,识别出人像,提取人像对应的第一图像特征区域;通过物体识别神经网络模型,识别出物体,提取人像物体的第一图像特征区域;然后,可以采用如上述步骤A2的方式人像对应的第一图像特征区域提取到第二特征区域。
在一些申请实施例中,当待压缩图像中包括人像和物体时,本申请实施例可以通过如上 述步骤a11至步骤a13的方式提取到对应的第一图像特征区域,第一图像特征区域为人像和物体的特征区域;然后,采用如上述步骤A2的方式从第一图像特征区域提取到人像对应的第二特征区域。
S103、获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域。
其中,压缩参数可以是压缩率。每一个图像特征区域具有对应的压缩参数,本申请实施例可以基于每个图像特征区域对应的压缩参数,对每个图像特征区域分别压缩,得到每个图像特征区域对应的压缩后图像区域。
其中,本申请实施例可以确定出每一图像特征区域的重要程度,按照重要程度对图像特征区域进行排序可以为:第二图像特征区域比第一图像特征区域重要,第一图像特征区域比第三图像特征区域重要。基于此,本申请实施例可以按照重要程度分别采用不同的压缩率对每一图像特征区域进行不同程度的压缩。
基于上述,本申请实施例的第二图像特征区域的压缩率大于第一图像特征区域的压缩率,第一图像特征区域的压缩率大于第三图像特征区域的压缩率。
其中,第二图像特征区域的压缩率可以大于0.8,第一图像特征区域的压缩率和第三图像特征区域的压缩率均可以大于0.6。
在本申请实施例中,第二图像特征区域的压缩率可以为0.8;第一图像特征区域的压缩率可以为0.6;第三图像特征区域的压缩率可以为0.5。
其中,本申请实施例可以通过Canvas中的图像压缩接口,例如to Blob API根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域。
S104、根据压缩后图像区域,生成压缩后图像。
本申请实施例根据压缩后图像区域,生成压缩后图像的方式可以为:获取图像特征区域在目标坐标系中的初始坐标点;根据初始坐标点,对图像特征区域对应的压缩后图像区域进行合并,得到合并后图像;根据合并后图像,确定压缩后图像。
此处需要说明的是,本申请实施例的待压缩图像在Canvas中时,具有对应的目标坐标系。本申请实施例中,待压缩图像的每个像素点在目标坐标系中具有对应的初始坐标点。基于此,本申请实施例在提取图像特征区域时,可以标注每一图像特征区域在待压缩图像中对应的初始坐标点。而压缩后图像区域的尺寸不变,基于此,本申请实施例可以基于初始坐标点,对图像特征区域对应的压缩后图像区域进行拼接,得到合并后图像。
其中,合并后图像即为压缩后图像。
其中,压缩后图像的格式可以为image/jpeg或者image/webp。
其中,本申请实施例的压缩后图像可以通图像转换接口输出,其中图像转换接口可以为window.URL.create Object URL(blob)。图像转换接口可以是指将图像数据转换为图像的接口。
本申请实施例可以获取待压缩图像,待压缩图像中包括目标对象;根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像;由于本申请实施例可以基于待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域,并利用图像特征区域对应的压缩参数对图像特征区域进行压缩处理,以保留图像特征区域中的关键信息,从而提高压缩后图像的清晰度。
为了更好地实施以上方法,本申请实施例还提供一种图像压缩装置,该图像压缩装置可以集成在计算机设备,比如服务器或终端等设备中,该终端可以包括平板电脑、笔记本电脑和/或个人计算机等。
例如,如图7所示,该图像压缩装置可以包括获取单元301、确定单元302、压缩单元 303和生成单元304,如下:
(1)获取单元301;
获取单元301,可以用于获取待压缩图像,待压缩图像中包括目标对象。
(2)确定单元302;
确定单元302,可以用于根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域。
在一些实施例中,多个图像特征区域包括第一图像特征区域、第二图像特征区域和第三图像特征区域;确定单元302,具体可以用于根据待压缩图像中像素点的通道值对目标对象进行边界识别,以从待压缩图像中确定第一图像特征区域;根据第一图像特征区域中像素点的通道值对目标对象进行特征识别,以从第一图像特征区域中提取第二图像特征区域;根据第一图像特征区域,从待压缩图像中确定第三图像特征区域,第三图像特征区域不包含目标对象。
在一些实施例中,确定单元302,具体可以用于根据待压缩图像中像素点的通道值,确定待压缩图像的灰度图像;根据灰度图像中像素点的灰度值,识别目标对象的对象边界;根据对象边界,从待压缩图像中提取与目标对象匹配的第一图像特征区域。
在一些实施例中,确定单元302,具体可以用于确定待压缩图像中像素点的像素类型;根据像素类型,确定像素点对应的灰度计算策略;根据像素点的通道值,采用灰度计算策略计算像素点的候选灰度值;根据候选灰度值,生成待压缩图像的灰度图像。
在一些实施例中,确定单元302,具体可以用于确定待压缩图像中像素点的位置;根据像素点的位置,确定像素点的像素类型。
在一些实施例中,灰度计算策略包括第一灰度计算策略和第二灰度计算策略;确定单元302,具体可以用于获取待压缩图像中像素点的像素类型;若像素类型为边缘像素类型,则根据像素点的通道值,采用第一灰度计算策略计算像素点的候选灰度值;若像素类型不为边缘像素类型,则根据像素点的通道值,采用第二灰度计算策略计算像素点的候选灰度值。
在一些实施例中,确定单元302,具体可以用于采用第一灰度计算策略对像素点的通道值进行计算,得到第一计算后通道值;根据第一计算后通道值,确定像素点的候选灰度值。
在一些实施例中,确定单元302,具体可以用于采用第二灰度计算策略对像素点的通道值进行计算,得到第二计算后通道值;根据第二计算后通道值,确定像素点的候选灰度值。
在一些实施例中,确定单元302,具体可以用于根据灰度图像中像素点的灰度值,确定灰度图像中灰度值为目标灰度值的目标像素点;根据目标像素点,确定目标对象在待压缩图像中的对象边界。
在一些实施例中,确定单元302,具体可以用于获取灰度图像在目标坐标系下的坐标;根据灰度图像中像素点的灰度值,提取坐标下灰度值为目标灰度值的候选像素点的数量;根据候选像素点的数量,确定灰度图像中灰度值为目标灰度值的目标像素点。
在一些实施例中,确定单元302,具体可以用于根据候选像素点的数量,从坐标中确定具有目标数量的候选像素点对应的目标坐标;根据目标坐标,从候选像素点中提取满足预设数量比例的目标像素点,以得到灰度图像中灰度值为目标灰度值的目标像素点。
在一些实施例中,确定单元302,具体可以用于根据第一图像特征区域中像素点的通道值,确定第一图像特征区域中像素点的区域特征值;根据第一图像特征区域中像素点的目标通道值和区域特征值,确定像素点的目标像素值;根据目标像素值,从第一图像特征区域中提取与目标对象匹配的第二图像特征区域。
在一些实施例中,确定单元302,具体可以用于将第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值;根据融合后通道值,确定第一图像特征区域中像素点的区域特征值。
在一些实施例中,候选通道值包括第一候选通道值和第二候选通道值;确定单元302,具体可以用于采用第一融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第一初始融合后通道值;采用第二融合函数对第一候选通道值和第二候选通道值进行融合处理,得到第二初始融合后通道值;采用第三融合函数对第一初始融合后通道值和第二初始融合后通道值进行融合处理,得到融合后通道值。
在一些实施例中,目标像素值包括第一目标像素值和第二目标像素值;确定单元302,具体可以用于若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值小于第一特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值小于通道值阈值,且区域特征值大于或等于第一特征值阈值时,确定像素点的目标像素值为第二目标像素值。
在一些实施例中,目标像素值包括第一目标像素值和第二目标像素值;确定单元302,具体可以用于若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值小于第二特征值阈值时,确定像素点的目标像素值为第一目标像素值;若第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且区域特征值大于或等于第二特征值阈值时,确定像素点的目标像素值为第二目标像素值。
(3)压缩单元303;
压缩单元303,可以用于获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域。
(4)生成单元304;
生成单元304,可以用于根据压缩后图像区域,生成压缩后图像。
在一些实施例中,生成单元304,具体可以用于获取图像特征区域在目标坐标系中的初始坐标点;根据初始坐标点,对图像特征区域对应的压缩后图像区域进行合并,得到合并后图像;根据合并后图像,确定压缩后图像。
由上可知,本申请实施例的获取单元301可以用于获取待压缩图像,待压缩图像中包括目标对象;确定单元302可以用于根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;压缩单元303可以用于获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;生成单元304可以用于根据压缩后图像区域,生成压缩后图像;由于本申请实施例可以基于待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域,并利用图像特征区域对应的压缩参数对图像特征区域进行压缩处理,以保留图像特征区域中的关键信息,从而提高压缩后图像的清晰度。
本申请实施例还提供一种计算机设备,如图8所示,其示出了本申请实施例所涉及的计算机设备的结构示意图,具体来讲:
该计算机设备可以包括一个或者一个以上处理核心的处理器401、一个或一个以上计算机可读存储介质的存储器402、电源403和输入单元404等部件。本领域技术人员可以理解,图8中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
处理器401是该计算机设备的控制中心,利用各种接口和线路连接整个计算机设备的各个部分,通过运行或执行存储在存储器402内的软件程序和/或模块,以及调用存储在存储器402内的数据,执行计算机设备的各种功能和处理数据。可选的,处理器401可包括一个或多个处理核心;优选的,处理器401可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和计算机程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器401中。
存储器402可用于存储软件程序以及模块,处理器401通过运行存储在存储器402的 软件程序以及模块,从而执行各种功能应用以及数据处理。存储器402可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的计算机程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机设备的使用所创建的数据等。此外,存储器402可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器402还可以包括存储器控制器,以提供处理器401对存储器402的访问。
计算机设备还包括给各个部件供电的电源403,优选的,电源403可以通过电源管理系统与处理器401逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源403还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。
该计算机设备还可包括输入单元404,该输入单元404可用于接收输入的数字或字符信息通讯,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。
尽管未示出,计算机设备还可以包括显示单元等,在此不再赘述。具体在本实施例中,计算机设备中的处理器401会按照如下的指令,将一个或一个以上的计算机程序的进程对应的可执行文件加载到存储器402中,并由处理器401来运行存储在存储器402中的计算机程序,从而实现各种功能,如下:
获取待压缩图像,待压缩图像中包括目标对象;根据待压缩图像中像素点的通道值,确定待压缩图像中与目标对象匹配的多个图像特征区域;获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;根据压缩后图像区域,生成压缩后图像。
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过计算机程序来完成,或通过计算机程序控制相关的硬件来完成,该计算机程序可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。
为此,本申请实施例提供一种计算机可读存储介质,其中存储有计算机程序,该计算机程序能够被处理器进行加载,以执行本申请实施例所提供的任一种图像压缩方法。
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。
其中,该计算机可读存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。
由于该计算机可读存储介质中所存储的指令,可以执行本申请实施例所提供的任一种图像压缩方法中的步骤,因此,可以实现本申请实施例所提供的任一种图像压缩方法所能实现的有益效果,详见前面的实施例,在此不再赘述。
其中,根据本申请的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述实施例提供的各种可选实现方式中提供的方法。
以上对本申请实施例所提供的一种图像压缩方法、装置、计算机设备及计算机可读存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。

Claims (20)

  1. 一种图像压缩方法,其中,包括:
    获取待压缩图像,所述待压缩图像中包括目标对象;
    根据所述待压缩图像中像素点的通道值,确定所述待压缩图像中与所述目标对象匹配的多个图像特征区域;
    获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;
    根据所述压缩后图像区域,生成压缩后图像。
  2. 根据权利要求1所述图像压缩方法,其中,所述多个图像特征区域包括第一图像特征区域、第二图像特征区域和第三图像特征区域;所述根据所述待压缩图像中像素点的通道值,确定所述待压缩图像中与所述目标对象匹配的多个图像特征区域,包括:
    根据所述待压缩图像中像素点的通道值对所述目标对象进行边界识别,以从所述待压缩图像中确定第一图像特征区域;
    根据所述第一图像特征区域中像素点的通道值对所述目标对象进行特征识别,以从所述第一图像特征区域中提取第二图像特征区域;
    根据所述第一图像特征区域,从所述待压缩图像中确定第三图像特征区域,所述第三图像特征区域不包含所述目标对象。
  3. 根据权利要求2所述的图像压缩方法,其中,所述根据所述待压缩图像中像素点的通道值对所述目标对象进行边界识别,以从所述待压缩图像中确定第一图像特征区域,包括:
    根据所述待压缩图像中像素点的通道值,确定所述待压缩图像的灰度图像;
    根据所述灰度图像中像素点的灰度值,识别所述目标对象的对象边界;
    根据所述对象边界,从所述待压缩图像中提取与所述目标对象匹配的第一图像特征区域。
  4. 根据权利要求3所述的图像压缩方法,其中,所述根据所述待压缩图像中像素点的通道值,确定所述待压缩图像的灰度图像,包括:
    确定所述待压缩图像中像素点的像素类型;
    根据所述像素类型,确定所述像素点对应的灰度计算策略;
    根据所述像素点的通道值,采用所述灰度计算策略计算所述像素点的候选灰度值;
    根据所述候选灰度值,生成所述待压缩图像的灰度图像。
  5. 根据权利要求4所述的图像压缩方法,其中,所述确定所述待压缩图像中像素点的像素类型,包括:
    确定所述待压缩图像中像素点的位置;
    根据所述像素点的位置,确定所述像素点的像素类型。
  6. 根据权利要求4所述的图像压缩方法,其中,所述灰度计算策略包括第一灰度计算策略和第二灰度计算策略;所述根据所述像素点的通道值,采用所述灰度计算策略计算所述像素点的候选灰度值,包括:
    获取所述待压缩图像中像素点的像素类型;
    若所述像素类型为边缘像素类型,则根据所述像素点的通道值,采用所述第一灰度计算策略计算所述像素点的候选灰度值;
    若所述像素类型不为边缘像素类型,则根据所述像素点的通道值,采用所述第二灰度计算策略计算所述像素点的候选灰度值。
  7. 根据权利要求6所述的图像压缩方法,其中,所述根据所述像素点的通道值,采用所述第一灰度计算策略计算所述像素点的候选灰度值,包括:
    采用所述第一灰度计算策略对所述像素点的通道值进行计算,得到第一计算后通道值;
    根据所述第一计算后通道值,确定所述像素点的候选灰度值。
  8. 根据权利要求6所述的图像压缩方法,其中,所述根据所述像素点的通道值,采用所述第二灰度计算策略计算所述像素点的候选灰度值,包括:
    采用所述第二灰度计算策略对所述像素点的通道值进行计算,得到第二计算后通道值;
    根据所述第二计算后通道值,确定所述像素点的候选灰度值。
  9. 根据权利要求3所述的图像压缩方法,其中,所述根据所述灰度图像中像素点的灰度值,识别所述目标对象的对象边界,包括:
    根据所述灰度图像中像素点的灰度值,确定所述灰度图像中灰度值为目标灰度值的目标像素点;
    根据所述目标像素点,确定所述目标对象在所述待压缩图像中的 对象边界。
  10. 根据权利要求9所述的图像压缩方法,其中,所述根据所述灰度图像中像素点的灰度值,确定所述灰度图像中灰度值为目标灰度值的目标像素点,包括:
    获取所述灰度图像在目标坐标系下的坐标;
    根据所述灰度图像中像素点的灰度值,提取所述坐标下灰度值为目标灰度值的候选像素点的数量;
    根据所述候选像素点的数量,确定所述灰度图像中灰度值为目标灰度值的目标像素点。
  11. 根据权利要求10所述的图像压缩方法,其中,所述根据所述候选像素点的数量,确定所述灰度图像中灰度值为目标灰度值的目标像素点,包括:
    根据所述候选像素点的数量,从所述坐标中确定具有目标数量的候选像素点对应的目标坐标;
    根据所述目标坐标,从所述候选像素点中提取满足预设数量比例的目标像素点,以得到所述灰度图像中灰度值为目标灰度值的目标像素点。
  12. 根据权利要求2所述的图像压缩方法,其中,所述根据所述第一图像特征区域中像素点的通道值对所述目标对象进行特征识别,以从所述第一图像特征区域中提取第二图像特征区域,包括:
    根据所述第一图像特征区域中像素点的通道值,确定所述第一图像特征区域中像素点的区域特征值;
    根据所述第一图像特征区域中像素点的目标通道值和所述区域特征值,确定所述像素点的目标像素值;
    根据所述目标像素值,从所述第一图像特征区域中提取与所述目标对象匹配的第二图像特征区域。
  13. 根据权利要求12所述的图像压缩方法,其中,所述根据所述第一图像特征区域中像素点的通道值,确定所述第一图像特征区域中像素点的区域特征值,包括:
    将所述第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值;
    根据所述融合后通道值,确定所述第一图像特征区域中像素点的区域特征值。
  14. 根据权利要求13所述的图像压缩方法,其中,所述候选通道值包括第一候选通道值和第二候选通道值;所述将所述第一图像特征区域中像素点的通道值中的候选通道值进行融合处理,得到融合后通道值,包括:
    采用第一融合函数对所述第一候选通道值和所述第二候选通道值进行融合处理,得到第一初始融合后通道值;
    采用第二融合函数对所述第一候选通道值和所述第二候选通道值进行融合处理,得到第二初始融合后通道值;
    采用第三融合函数对所述第一初始融合后通道值和所述第二初始融合后通道值进行融合处理,得到融合后通道值。
  15. 根据权利要求12所述的图像压缩方法,其中,所述目标像 素值包括第一目标像素值和第二目标像素值;所述根据所述第一图像特征区域中像素点的目标通道值和所述区域特征值,确定所述像素点的目标像素值,包括:
    若所述第一图像特征区域中像素点的目标通道值小于通道值阈值,且所述区域特征值小于第一特征值阈值时,确定所述像素点的目标像素值为第一目标像素值;
    若所述第一图像特征区域中像素点的目标通道值小于通道值阈值,且所述区域特征值大于或等于第一特征值阈值时,确定所述像素点的目标像素值为第二目标像素值。
  16. 根据权利要求12所述的图像压缩方法,其中,所述目标像素值包括第一目标像素值和第二目标像素值;所述根据所述第一图像特征区域中像素点的目标通道值和所述区域特征值,确定所述像素点的目标像素值,包括:
    若所述第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且所述区域特征值小于第二特征值阈值时,确定所述像素点的目标像素值为第一目标像素值;
    若所述第一图像特征区域中像素点的目标通道值大于或等于通道值阈值,且所述区域特征值大于或等于第二特征值阈值时,确定所述像素点的目标像素值为第二目标像素值。
  17. 根据权利要求1所述的图像压缩方法,其中,所述根据所述压缩后图像区域,生成压缩后图像,包括:
    获取所述图像特征区域在目标坐标系中的初始坐标点;
    根据所述初始坐标点,对所述图像特征区域对应的压缩后图像区域进行合并,得到合并后图像;
    根据所述合并后图像,确定所述压缩后图像。
  18. 一种图像压缩装置,其中,包括:
    获取单元,用于获取待压缩图像,所述待压缩图像中包括目标对象;
    确定单元,用于根据所述待压缩图像中像素点的通道值,确定所述待压缩图像中与所述目标对象匹配的多个图像特征区域;
    压缩单元,用于获取每个图像特征区域对应的压缩参数,并根据每个图像特征区域对应的压缩参数,分别对每个图像特征区域进行压缩处理,得到压缩后图像区域;
    生成单元,用于根据所述压缩后图像区域,生成压缩后图像。
  19. 一种计算机设备,其中,包括存储器和处理器;所述存储器存储有计算机程序,所述处理器用于运行所述存储器内的计算机程序,以执行权利要求1至17任一项所述的图像压缩方法。
  20. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序适于处理器进行加载,以执行权利要求1至17任一项所述的图像压缩方法。
PCT/CN2023/102672 2022-09-15 2023-06-27 图像压缩方法、装置、计算机设备及计算机可读存储介质 WO2024055676A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211125051.8A CN117173261A (zh) 2022-09-15 2022-09-15 图像压缩方法、装置、计算机设备及计算机可读存储介质
CN202211125051.8 2022-09-15

Publications (1)

Publication Number Publication Date
WO2024055676A1 true WO2024055676A1 (zh) 2024-03-21

Family

ID=88930506

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/102672 WO2024055676A1 (zh) 2022-09-15 2023-06-27 图像压缩方法、装置、计算机设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN117173261A (zh)
WO (1) WO2024055676A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102647590A (zh) * 2012-04-17 2012-08-22 华为终端有限公司 图像压缩方法和装置
CN105721872A (zh) * 2016-01-29 2016-06-29 广东欧珀移动通信有限公司 一种图像压缩的方法及终端
US20200034993A1 (en) * 2018-07-24 2020-01-30 Apical Ltd Processing image data using different data reduction rates
CN113470127A (zh) * 2021-09-06 2021-10-01 成都国星宇航科技有限公司 基于星载云检测的光学图像有效压缩方法
CN114827625A (zh) * 2022-04-27 2022-07-29 武汉大学 一种基于灰度图压缩算法的高速图像云传输方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102647590A (zh) * 2012-04-17 2012-08-22 华为终端有限公司 图像压缩方法和装置
CN105721872A (zh) * 2016-01-29 2016-06-29 广东欧珀移动通信有限公司 一种图像压缩的方法及终端
US20200034993A1 (en) * 2018-07-24 2020-01-30 Apical Ltd Processing image data using different data reduction rates
CN113470127A (zh) * 2021-09-06 2021-10-01 成都国星宇航科技有限公司 基于星载云检测的光学图像有效压缩方法
CN114827625A (zh) * 2022-04-27 2022-07-29 武汉大学 一种基于灰度图压缩算法的高速图像云传输方法

Also Published As

Publication number Publication date
CN117173261A (zh) 2023-12-05

Similar Documents

Publication Publication Date Title
CN110163198B (zh) 一种表格识别重建方法、装置和存储介质
JP6636154B2 (ja) 顔画像処理方法および装置、ならびに記憶媒体
CN107025457B (zh) 一种图像处理方法和装置
US11030439B2 (en) Facial expression synthesis method and apparatus, electronic device, and storage medium
CN114155543B (zh) 神经网络训练方法、文档图像理解方法、装置和设备
WO2021164550A1 (zh) 图像分类方法及装置
US9092668B2 (en) Identifying picture areas based on gradient image analysis
US20110050723A1 (en) Image processing apparatus and method, and program
WO2018153264A1 (zh) 一种图像处理的方法及装置
CN112614060A (zh) 人脸图像头发渲染方法、装置、电子设备和介质
JP2018045693A (ja) 動画像背景除去方法及び動画像背景除去システム
CN110728722B (zh) 图像颜色迁移方法、装置、计算机设备和存储介质
US20230094362A1 (en) Image processing method and apparatus, and computer-readable storage medium
CN106327453B (zh) 一种拼合图片资源的方法及图片资源拼合装置
WO2022135574A1 (zh) 肤色检测方法、装置、移动终端和存储介质
WO2022135579A1 (zh) 肤色检测方法、装置、移动终端和存储介质
CN111080746A (zh) 图像处理方法、装置、电子设备和存储介质
CN113301409A (zh) 视频合成方法、装置、电子设备和可读存储介质
TW202242804A (zh) 用於影像處理的方法、裝置、電子設備及儲存媒體
CN109166172B (zh) 服装模型的构建方法、装置、服务器和存储介质
CN111062868A (zh) 一种图像处理方法、装置、机器可读介质及设备
EP3869466A1 (en) Method and device for picture generation, electronic device, and storage medium
CN115689882A (zh) 一种图像处理方法、装置和计算机可读存储介质
WO2024055676A1 (zh) 图像压缩方法、装置、计算机设备及计算机可读存储介质
CN112150347A (zh) 从有限的修改后图像集合中学习的图像修改样式

Legal Events

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

Ref document number: 23864415

Country of ref document: EP

Kind code of ref document: A1