Photo preview method, electronic device and storage medium

By preprocessing and predicting algorithm calculations of photos stored in YUV format, Y components are extracted and spliced, the problem of low efficiency and memory usage of mobile terminals when previewing high-resolution images is solved, and faster data reading and Processing improves user experience.

CN118918198BActive Publication Date: 2024-12-06深圳市云希谷科技有限公司
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411413194.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2024-12-06
Estimated Expiration
2044-10-11

AI Technical Summary

Technical Problem

When a mobile terminal previews high-resolution and large-capacity images, the processor reads data from the data buffer too slowly, resulting in low preview efficiency and large memory space, which can easily cause data overflow and system lag.

Method used

Image preprocessing is performed using photos stored in YUV format, using prediction algorithms to extract the Y components of the image data, and stitching and synthesis into a complete preview photo, reducing the amount of data to be read, reducing memory usage, and improving data reading efficiency.

Benefits of technology

Without losing image quality, the memory space occupied by mobile terminals when previewing photos is reduced, data reading and processing efficiency is improved, and a smoother and instant preview experience is provided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918198B_ABST
    Figure CN118918198B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and discloses a photo preview method, electronic device and storage medium. The method comprises obtaining a photo to be previewed stored in a YUV format; performing image preprocessing on the photo to be previewed to obtain a processed image; calculating the processed image using a prediction algorithm to obtain a Y component of image data; splicing the Y component of the image data to synthesize a complete preview photo; reading the complete preview photo, and returning the complete preview photo to a user. The method enables a mobile terminal to return a complete photo to a user by only reading a small portion of features of the photo to be previewed, thereby reducing the memory space occupied by the mobile terminal when previewing photos and improving the efficiency of reading data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a photo preview method, electronic equipment and storage medium. Background Art

[0002] In today's society, taking photos has become a very common thing in people's daily lives. With the development and widespread application of smart terminals, photo-taking devices and functions are becoming more and more popular. While people take photos anytime and anywhere, they also have higher expectations for the effect of instant preview of photos after taking photos, hoping to get clear, delicate and color-accurate visual feedback in the first place.

[0003] Under the current technical framework, mobile terminals (such as mobile phones and tablets) all have built-in powerful preview functions. These devices capture image data through integrated camera modules and use efficient data interfaces (such as USB interfaces) to seamlessly connect to camera devices. After capturing image data, the camera device quickly transmits the data to the mobile terminal through the interface. Subsequently, the mobile terminal efficiently reads the image data in its internal data buffer, and after a series of complex image processing algorithm optimization, it finally presents the processing results on the display screen, realizing the picture preview function.

[0004] However, due to the limitations of factors such as size and power consumption, the performance of the built-in processor of mobile terminals is still insufficient compared to that of modern computers, which limits the ability of mobile terminals to process large-scale image data to a certain extent. When faced with high-resolution, large-capacity image data, the processor reads data from the data buffer too slowly, resulting in low preview efficiency. At the same time, due to the large size of image data, the time required for the mobile terminal to read data from the data buffer at one time is too long, and the memory space occupied is too large. Especially when the processing speed is slower than the acquisition speed, it is easy to cause data overflow and cannot be displayed in real time. In addition, the large amount of image data will occupy a large amount of memory space, resulting in tight memory resources of the mobile terminal, making it impossible to perform normal preview display, and even causing the entire system to become stuck or crash. Summary of the invention

[0005] The invention provides a photo preview method, an electronic device and a storage medium to solve the problem of low data reading efficiency and large space occupation when the device previews photos.

[0006] In a first aspect, in order to solve the above technical problem, the present invention provides a photo preview method, comprising:

[0007] Get the photo to be previewed stored in YUV format;

[0008] Performing image preprocessing on the photo to be previewed to obtain a processed image;

[0009] Using a prediction algorithm to calculate the processed image to obtain a Y component of image data;

[0010] splicing the Y components of the image data to synthesize a complete preview photo;

[0011] The complete preview photo is read and returned to the user.

[0012] In an optional embodiment, the photo to be previewed stored in the YUV format is composed of a number of pixels, and the pixels include an image data Y component, an image data U component and an image data V component; wherein the image data Y component carries the grayscale value information of the image; the image data U component carries the difference information between the blue and brightness of the image; and the image data V component carries the difference information between the red and brightness of the image.

[0013] In an optional implementation manner, performing image preprocessing on the photo to be previewed to obtain a processed image includes:

[0014] Performing an image deinterlacing operation on the photo to be previewed to obtain a photo to be denoised;

[0015] Performing an image noise reduction operation on the photo to be denoised to obtain the processed image;

[0016] The image deinterlacing operation includes removing redundant borders and background parts in the photo to be previewed; the image noise reduction operation includes using a filtering algorithm to calculate the photo to reduce noise in the photo;

[0017] The image denoising operation is performed according to the following formula:

[0018] ;

[0019] in, represents a matrix consisting of image pixels, represents the number of rows and columns of the matrix, and The value of is an odd number, Indicates the current row number. Indicates the current column number, Indicates the matrix Row, No. The elements of the column, represents the central element of the matrix.

[0020] In an optional implementation, the using a prediction algorithm to calculate the processed image to obtain the image data Y component includes:

[0021] Establishing a prediction unit in the processed image; wherein one prediction unit includes a macroblock, and one macroblock stores a plurality of brightness values;

[0022] Calculating an average brightness value of each prediction unit according to the brightness values ​​in all the macroblocks in each prediction unit;

[0023] Determine the size of the brightness value in each macroblock and the average brightness value; if the brightness value is less than the average brightness value, set the image data Y component of the current prediction unit to 0; if the brightness value is not less than the average brightness value, calculate the image data Y component of the current prediction unit according to the brightness value.

[0024] In an optional implementation manner, the stitching of the Y components of the image data to synthesize a complete preview photo includes:

[0025] Allocating a fixed-size memory space according to the photos to be previewed;

[0026] All the Y components of the image data are sequentially read in the memory space and spliced ​​to obtain the complete preview photo.

[0027] In an optional implementation, if the brightness value is not less than the average brightness value, calculating the image data Y component of the current prediction unit according to the brightness value includes:

[0028] According to the photo to be previewed, a color density offset is obtained; wherein the color density offset includes a blue density offset and a red density offset;

[0029] Calculating the Y component of the image data of the current prediction unit according to the color density offset;

[0030] The image data Y component is calculated according to the following formula:

[0031] ;

[0032] in, represents the calculated Y component of the image data, Represents the original Y component of the image data, Represents the U component of image data, Represents the image data V component, represents the blue concentration offset, Indicates the red density offset.

[0033] In an optional implementation manner, the sequentially reading all the Y components of the image data in the memory space and splicing them to obtain the complete preview photo includes:

[0034] Reading a Y component of the image data;

[0035] Acquire the position of the Y component of the image data already in the memory space to obtain a splicing position for splicing;

[0036] The read image data Y component is stored in the splicing position, and the next image data Y component is read, until the end position of the image data Y component is read, to obtain the complete preview photo.

[0037] In a second aspect, the present invention provides a photo preview device, comprising:

[0038] The photo acquisition module is used to acquire the photos to be previewed stored in YUV format;

[0039] A photo preprocessing module, used for performing image preprocessing on the photo to be previewed to obtain a processed image;

[0040] A photo calculation module, used to calculate the processed image using a prediction algorithm to obtain a Y component of image data;

[0041] A photo synthesis module, used for splicing the Y components of the image data to synthesize a complete preview photo;

[0042] The photo output module is used to read the complete preview photo and return the complete preview photo to the user.

[0043] In a third aspect, the present invention further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements any one of the above-mentioned photo preview methods when executing the computer program.

[0044] In a fourth aspect, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the photo preview methods described above.

[0045] Compared with the prior art, the present invention has the following beneficial effects:

[0046] The present invention provides a photo preview method, comprising acquiring a photo to be previewed stored in a YUV format; performing image preprocessing on the photo to be previewed to obtain a processed image; using a prediction algorithm to calculate the processed image to obtain a Y component of image data; splicing the Y component of the image data to synthesize a complete preview photo; reading the complete preview photo, and returning the complete preview photo to a user.

[0047] The method obtains the to-be-previewed photo stored in the YUV format, performs image preprocessing on the to-be-previewed photo, and uses a prediction algorithm to perform calculations to obtain key components of the to-be-previewed photo, and finally synthesizes the key components to obtain a complete preview photo and returns it to the user, so that the mobile terminal only needs to read a small part of the features of the to-be-previewed photo to return a relatively complete photo to the user, thereby reducing the memory space occupied by the mobile terminal when previewing photos and improving the efficiency of reading data. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 is a flowchart of a photo preview method provided by a first embodiment of the present invention;

[0049] Figure 2 It is a structural schematic diagram of a photo preview device provided by a second embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] Reference Figure 1 The first embodiment of the present invention provides a photo preview method, comprising the following steps:

[0052] S1, obtaining the photo to be previewed stored in YUV format;

[0053] S2, performing image preprocessing on the photo to be previewed to obtain a processed image;

[0054] S3, using a prediction algorithm to calculate the processed image to obtain a Y component of image data;

[0055] S4, stitching the Y components of the image data to synthesize a complete preview photo;

[0056] S5, reading the complete preview photo, and returning the complete preview photo to the user.

[0057] It should be noted that the processors on many mobile terminals today have a slow processing speed, especially when the acquired image data is large, the system reads such huge data from the data buffer too slowly, which directly leads to low preview efficiency. Due to the large size of the image file, each time the mobile terminal loads from the data buffer, it not only takes too long, but also consumes a lot of memory resources. In particular, when the image processing speed is slower than the acquisition speed, data overflow will occur, and it will not be displayed in real time. At the same time, the image data volume is too large, which will occupy a large amount of limited memory space, causing the memory resources of the mobile terminal to become increasingly tight, and even causing the inability to perform normal preview display. For example, when using a mobile phone to take a photo preview operation, it takes about 4.5 seconds to perform a complete photo preview. When the amount of data to be read from the data buffer is large, this time will be significantly extended. At this time, the processor's response speed lags significantly behind the data capture speed, resulting in frequent data overflows, and the effect of shooting and watching cannot be achieved. Therefore, users face poor experiences such as long waiting time and incoherent preview.

[0058] In the present invention, a photo preview method is designed so that the mobile terminal can quickly read photos and effectively reduce the memory burden. The core of the present invention is to first obtain the photos to be previewed stored in YUV format. Then, the photo to be previewed is image preprocessed, and the processed photo is calculated using a prediction algorithm pre-input into the mobile terminal to obtain the key components of the photo to be previewed. Finally, the key components are synthesized to obtain a complete preview photo and returned to the user. The method can return a relatively complete photo to the user without sacrificing too much image quality, so that the mobile terminal only needs to read a small part of the key features of the photo to be previewed, thereby not only reducing the memory space occupied by the mobile terminal when previewing photos, but also improving the efficiency of data reading and processing, bringing users a smoother and more instant photo preview experience.

[0059] In step S1, firstly, it is necessary to obtain the photos to be previewed that are taken by the user and stored in YUV format, and then store the photos to be previewed into a storage space for subsequent use.

[0060] Specifically, first, the user uses the mobile terminal to take a photo, and the mobile terminal will use the built-in algorithm to automatically convert the taken photo into a YUV format for storage. Then the mobile terminal stores the previewed photo stored in the YUV format into the storage space of the mobile terminal. The previewed photo stored in the YUV format is composed of a number of pixels, and the pixels include image data Y component, image data U component and image data V component; the image data Y component carries the gray value information of the image; the image data U component carries the difference information between the blue and brightness of the image; the image data V component carries the difference information between the red and brightness of the image.

[0061] It should be noted that the YUV format reduces the bandwidth of chrominance (U and V components), so that when transmitting video signals of the same quality, the bandwidth required by the YUV format is much lower than that of the RGB format. The YUV format can significantly reduce the amount of data transmission while maintaining image quality. At the same time, since the sampling rate of the chrominance component of the YUV format is lower than that of the brightness component, it can more effectively remove redundant information and improve the compression ratio during the compression process. Therefore, photos stored in the YUV format can be better transmitted in the preview stage and reduce the memory space occupied. In addition, the YUV format also supports both color and black and white display devices, which is more in line with the visual perception characteristics of the human eye, and supports multiple sampling formats and storage modes, that is, it has the advantages of good compatibility, strong color expression, and easy processing. By using the YUV format to store photos, the user experience can be greatly improved.

[0062] It should be noted that the photos taken by the mobile terminal may have different default storage formats for the photos to be previewed due to different models and configurations of the mobile terminal. In this case, the mobile terminal needs to first determine whether the stored photos are in YUV format, and use the corresponding conversion algorithm to convert the photos that do not meet the conditions into YUV format storage, or perform format conversion when performing subsequent calculation operations. At the same time, when performing conversion and storage operations, it is necessary to strictly follow the principles of data integrity and accuracy so that users can obtain complete and accurate preview photos in subsequent previews.

[0063] In step S2, the photo to be previewed needs to be read from the storage space of the mobile terminal first, and then the photo to be previewed is preprocessed to obtain a processed image, and finally the processed image is stored in the storage space.

[0064] In one embodiment, the image preprocessing of the photo to be previewed to obtain a processed image includes: performing an image deinterlacing operation on the photo to be previewed to obtain a photo to be denoised; and performing an image denoising operation on the photo to be denoised to obtain the processed image.

[0065] Specifically, the photo to be previewed is first read from the storage space of the mobile terminal, and then the photo to be previewed is subjected to image deinterlacing and image noise reduction operations to obtain a processed image. The image deinterlacing operation includes removing redundant borders and background parts in the photo to be previewed to reduce the amount of subsequent calculations; the image noise reduction operation includes using an image mean filtering algorithm to calculate the photo to reduce the noise in the photo; the image noise reduction operation is performed according to the following formula:

[0066] ;

[0067] in, represents a matrix consisting of image pixels, represents the number of rows and columns of the matrix, and The value of is an odd number, Indicates the current row number. Indicates the current column number, Indicates the matrix Row, No. The elements of the column, Represents the central element of the matrix. The image mean filtering algorithm is a commonly used smoothing technique in image processing, which is mainly used to remove random noise in images. By replacing the value of each pixel in the image with the average value of the pixels in its neighborhood, the purpose of smoothing the image is achieved. Mean filtering can effectively reduce random noise in the image, but it may blur the edges of the image and fail to retain the detailed information of the image well.

[0068] In another embodiment, the image mean filter algorithm may be replaced by an image Gaussian filter algorithm to better perform the image denoising operation. The image Gaussian filter denoising operation is performed according to the following formula:

[0069] ;

[0070] ;

[0071] in, represents a matrix consisting of image pixels, Represents the matrix of the image after Gaussian filtering, Represents the horizontal coordinate of the pixel relative to the filter center, Represents the horizontal coordinate of the pixel relative to the filter center, represents the standard deviation of the Gaussian function, represents the Gaussian function, represents pi, Represents a natural constant. The principle of the image Gaussian filtering algorithm is to perform a weighted average of the pixels around each pixel in the image. This weighted average method gives higher weights to pixels closer to the center pixel, which not only effectively suppresses image noise, but also achieves a more delicate and smooth visual effect. At the same time, most of the noise in the photo is Gaussian noise, and the image Gaussian filtering algorithm has a better processing effect on Gaussian noise. Therefore, compared with the image mean filtering algorithm, using the image Gaussian filtering algorithm for noise reduction can achieve better results.

[0072] It should be noted that the image denoising operations are diverse, mainly including filter-based methods, model-based methods and learning-based methods, a total of three categories of methods. The three categories of methods have their own advantages and disadvantages. When performing specific denoising operations, you can choose a more suitable denoising method according to your needs. The model-based method is good at using prior knowledge of the image to optimize the denoising effect; while the learning-based method, with the help of big data and deep learning technology, can automatically learn and adapt to complex noise patterns to achieve higher quality denoising. However, in the scenario of image denoising on mobile terminals, since the processor performance of mobile terminals is generally lower than that of computers, filter-based image denoising methods with general denoising effects but low resource dependence are often selected.

[0073] Furthermore, the image preprocessing may also include rotating, flipping, scaling, and cropping the image or any combination of several operations. Among them, rotation, flipping, and scaling are all based on the center of the image, and cropping is preferably performed in the center of the screen. In addition, since the screen of the mobile terminal or the display window of the software is generally rectangular, the image needs to be rotated when displayed on the rectangular screen, and the length and width of the image and the screen need to be adjusted to ensure that the image is fully displayed on the screen. In order to ensure that the image can be fully displayed on the screen, the cropping window needs to extend from the center of the image to the surroundings so that it can cover the entire display area of ​​the screen.

[0074] In step S3, the processed image is first read from the storage space, and then the processed image is calculated using a prediction algorithm to obtain the image data Y component and store it in the storage space.

[0075] In one embodiment, the process of calculating the processed image using a prediction algorithm to obtain the image data Y component comprises the following steps:

[0076] S31, establishing a prediction unit in the processed image.

[0077] S32: Calculate an average brightness value of each prediction unit according to the brightness values ​​in all the macroblocks in each prediction unit.

[0078] S33, determine the size of the brightness value in each of the macroblocks and the average brightness value; if the brightness value is less than the average brightness value, set the image data Y component of the current prediction unit to 0; if the brightness value is not less than the average brightness value, calculate the image data Y component of the current prediction unit according to the brightness value.

[0079] In step S31, a prediction unit is established in the processed image, and the prediction unit is smoothed to traverse the entire processed image. Wherein, one prediction unit includes one macroblock, and one macroblock stores a plurality of brightness values.

[0080] Specifically, it is first necessary to establish a series of prediction units with specific sizes in the processing image. The size of the prediction unit is generally set according to the size of the processing image and in accordance with practical experience. Then, the prediction unit will slide in the processing image, thereby gradually traversing the entire processing image. Among them, the prediction unit mainly reads the image data Y component within a certain range of the processing image, and other components are ignored.

[0081] It should be noted that the specific size of the prediction unit should generally be set according to experience, and multiple tests and verifications are required to ensure that the selected size can achieve the best smoothing effect while retaining the key details of the image. If the prediction unit size is set too large, then when the average value is calculated later, although the calculation efficiency may be improved, it will cause the smoothing operation to cross too many areas with significant color differences, making the final preview image appear too smooth in color transition and lose important detail information; if the prediction unit size is set too small, then when the average value is calculated later, although more details can be captured, the amount of calculation will be significantly increased, which will not only fail to effectively reduce the storage space occupied by the image file, but may also affect the smoothness and efficiency of the preview due to the averaging of too many subtle differences.

[0082] In step S32, the brightness values ​​in all the macroblocks in each prediction unit are read, and the average brightness value of each prediction unit is calculated respectively.

[0083] Specifically, the brightness values ​​contained in all the macroblocks are first read from each prediction unit, and then the average brightness value of each prediction unit is calculated respectively. Each prediction unit contains a number of brightness values, and the number of brightness values ​​is strictly limited to the preset prediction unit size, so as to ensure the accuracy and consistency of data processing.

[0084] It should be noted that the brightness value represents the brightness of the image pixel, and its value range is limited to integers between 0 and 255. Therefore, when calculating the average brightness value, it is also necessary to round the average brightness value obtained to ensure the correctness of subsequent calculations.

[0085] In step S33, it is necessary to judge the size of the brightness value in each macroblock and the average brightness value; if the brightness value is less than the average brightness value, the image data Y component of the current prediction unit is set to 0; if the brightness value is not less than the average brightness value, the image data Y component of the current prediction unit is calculated according to the brightness value.

[0086] In one embodiment, if the brightness value is not less than the average brightness value, the image data Y component of the current prediction unit is calculated according to the brightness value, including obtaining a color density offset according to the photo to be previewed; wherein the color density offset includes a blue density offset and a red density offset; according to the color density offset, the image data Y component of the current prediction unit is calculated; wherein the image data Y component is calculated according to the following formula,

[0087] ;

[0088] in, represents the calculated Y component of the image data, Represents the original Y component of the image data, Represents the U component of image data, Represents the image data V component, represents the blue concentration offset, Represents the red concentration offset. It should be noted that the image data Y component carries the grayscale value information of the image; the image data U component carries the difference information between the blue and brightness of the image; and the image data V component carries the difference information between the red and brightness of the image. For example, in some cases, it is necessary to adjust the brightness according to the relative intensity of blue and red in the image to improve the visual effect of the image or perform specific image analysis tasks. If the blue concentration offset is greater than the red concentration offset, the image will look brighter; conversely, if the red concentration offset is larger, the image will look darker.

[0089] Specifically, first, the color density offset is obtained according to the photo to be previewed. Then, according to the color density offset, the image data Y component of the current prediction unit is calculated using a set calculation formula. Finally, the above calculation process is repeated, and for each prediction unit after smoothing, the image data Y component value of the prediction unit is calculated again until the image data Y components of all the prediction units are calculated.

[0090] It should be noted that the color density offset includes a blue density offset and a red density offset, which together reflect the change in the color density of the image. The blue density offset and the red density offset come from images stored in the YCbCr format. Furthermore, the color density offset can be obtained by converting a photo stored in the YUV format into a photo stored in the YCbCr format. The conversion of a photo stored in the YUV format to a photo stored in the YCbCr format is achieved according to the following formula:

[0091] ;

[0092] ;

[0093] in, Represents the U component of image data, Represents the image data V component, represents the blue concentration offset, represents the red concentration offset, Indicates the scaling factor of the blue density offset converted from the U component of the image data. Indicates the scaling factor of the red density offset converted by the V component of the image data. Meanwhile, the letter Y in both formats indicates the Y component of the image data, that is, the brightness value, and therefore remains unchanged.

[0094] Furthermore, the YUV format is an image format that uses the YUV color encoding method, and the image sampling format is generally represented by the ratio of the three components Y, U, and V, such as 4:4:4. Common sampling formats include 4:2:2 and 4:2:0. In order to facilitate the understanding of the present invention, some preferred embodiments of this step will be further described below.

[0095] In a preferred embodiment, the sampling format of the picture is 4:2:2. In step S31, the prediction unit selects 16 adjacent macroblocks and their corresponding 16 image data Y components; in step S32, the brightness average is the average of the 16 brightness values; in step S33, the 16 brightness values ​​are used as the basis for calculating the prediction value. The image data with the sampling format of 4:2:2 can appropriately reduce the data volume by using the present invention to ensure the image preview speed.

[0096] In another preferred embodiment, the sampling format of the picture is 4:2:0. In step S31, the prediction unit selects 8 adjacent macroblocks and 8 image data Y components of their odd rows; in step S32, the brightness average is the average of the 8 brightness Y data values; in step S23, the 8 brightness values ​​are used as the basis for calculating the prediction value. The image data with the sampling format of 4:2:0 can further reduce the data volume by using the present invention to ensure the image preview speed.

[0097] In step S4, all the predicted image data Y components are obtained and spliced ​​in order to synthesize a complete preview photo, including the following steps:

[0098] S41, allocating a fixed-size memory space according to the photo to be previewed;

[0099] S42, reading all the Y components of the image data in the memory space in sequence, and splicing them to obtain the complete preview photo.

[0100] In step S41, it is necessary to allocate a space of a corresponding size in the memory space according to the photo to be previewed to store the complete preview photo.

[0101] Specifically, the photo to be previewed is first read, and the size of the photo to be previewed in the memory space is calculated. Then, according to the size of the storage space occupied by the photo to be previewed, a space of the same size is allocated in the memory space to store the complete preview photo obtained by subsequent synthesis. In particular, since the key features of the complete preview photo are judged and selected during the synthesis process, and the remaining features are discarded, so that the occupied space is reduced, the space can be appropriately reduced relative to the photo to be previewed.

[0102] In step S42, firstly, all the Y components of the image data need to be read in sequence in the memory space, and then spliced ​​in sequence to obtain the complete preview photo.

[0103] In one embodiment, all the image data Y components are sequentially read in the memory space and stitched together to obtain the complete preview photo, including: reading one image data Y component; obtaining the position of the image data Y component already in the memory space to obtain the stitching position for stitching; storing the read image data Y component into the stitching position, and starting to read the next image data Y component until the end position of the image data Y component is read to obtain the complete preview photo.

[0104] Specifically, first, read one of the image data Y components in the buffer. Then, according to the storage table in the memory space, query how much unoccupied space is left in the currently allocated memory space, and use an intelligent algorithm to determine the splicing position for splicing according to the current image data Y component and the unoccupied space. Finally, store the currently read image data Y component in the splicing position, and determine whether there is any remaining allocated memory space; if there is, repeat the reading of the next image data Y component, query and determine the splicing position, and store the image data Y component in the splicing position; if there is no remaining, immediately save the data information in the allocated memory space to obtain the complete preview photo.

[0105] Furthermore, the stitching operation includes two meanings. On the one hand, multiple images are stored in the memory of the shooting device in a queue manner, the buffer is read, and the image data Y component of each frame data is read in sequence through the queue and stitched to generate a preview photo; on the other hand, in terms of pixel stitching, the read image data Y component is stitched, which ensures that each frame of the photo forms a whole, greatly facilitating subsequent image display and processing.

[0106] It should be noted that the image data Y component is the brightness information of the image data. After the read image data Y component is spliced, a preview photo is generated. The data of each pixel in the preview photo only contains brightness information, but does not contain the image data U component and the image data V component, that is, it is presented as a grayscale image and does not contain any color information. Therefore, after obtaining the preview photo, it is necessary to add the image data U component and the image data V component of the corresponding position to each pixel in the preview photo through image processing operations again, so as to add the corresponding color to the preview photo, thereby obtaining the complete preview photo.

[0107] It is worth noting that adding color information on the basis of Y actually combines the U and V components (chromaticity information) in the YUV color space with the Y component (brightness information) to obtain a complete color image. After obtaining the YUV components, YUV to RGB conversion is performed, and the Y, U, and V components can be converted to the RGB color space using the YUV to RGB conversion formula to obtain a complete color image. This process can be implemented using an image processing library such as OpenCV. For example, in OpenCV, the cv2.cvtColor function can be used to directly convert a YUV image to an RGB image, and the present invention does not limit this.

[0108] In step S5, the complete preview photo is first read from the storage space, and then the complete preview photo is returned to the user. During the return display process, the complete preview photo needs to be adjusted according to the size of the mobile terminal screen to ensure that the complete display can be brought to the user.

[0109] Furthermore, the display process can also use different devices, that is, take a photo with the first device, connect it to the second device with a data cable, and display the photo on the second device. For example, take a photo on a mobile phone, and then transfer the photo to a computer for display. Mobile phones are very convenient to carry around, but they have weak processors and small screens, making it difficult to see details during the display stage for users. Computers have more powerful processors and larger screens than mobile phones, and transferring the photos to a computer for viewing can better meet users' needs for high-resolution photos.

[0110] To facilitate understanding of the present invention, the working process of the present invention is described below using a common scenario as an example:

[0111] In this embodiment, a system capable of quickly performing photo preview is planned to be deployed in the mobile phone. The system is intended to quickly read the photographed photo and display the photo completely and quickly on the mobile phone screen for the user to perform real-time preview.

[0112] Step 1: Take a photo and store it in the phone storage in YUV format.

[0113] Step 2: Get the photo to be previewed stored in YUV format from the storage space.

[0114] Step three: perform corresponding image preprocessing operations on the photo to be previewed to obtain a processed image and store it.

[0115] Step 4: A prediction unit is established according to the processed image, and a prediction algorithm pre-stored in the device is used to calculate and judge the brightness value in the prediction unit to predict the Y component of the image data.

[0116] Step 5: Allocate memory space according to the photo to be previewed, and splice the image data Y component in the allocated memory space, and then add the corresponding image data U component and image data V component to obtain a complete preview photo.

[0117] Step 6: Read the complete preview photo and display the complete preview photo on the screen of the current device.

[0118] Through the above steps, the photo preview system can quickly read the taken photos, process the photos, and finally display the processed photos completely and quickly on the mobile phone screen, meeting the user's demand for real-time preview.

[0119] In summary, the present invention provides a photo preview method, including obtaining a photo to be previewed stored in a YUV format; performing image preprocessing on the photo to be previewed to obtain a processed image; using a prediction algorithm to calculate the processed image to obtain a Y component of image data; splicing the Y component of the image data to synthesize a complete preview photo; reading the complete preview photo, and returning the complete preview photo to the user. The method obtains the photo to be previewed stored in a YUV format, performs image preprocessing on the photo to be previewed, and then uses a prediction algorithm to calculate the processed image to obtain the key components of the photo to be previewed, and finally synthesizes the key components to obtain a complete preview photo and return it to the user, so that the mobile terminal only needs to read a small part of the key features of the photo to be previewed to provide the user with a relatively complete photo, thereby reducing the memory space occupied by the mobile terminal when previewing photos and improving the efficiency of reading photo data.

[0120] Reference Figure 2 The second embodiment of the present invention provides a photo preview device, comprising:

[0121] The photo acquisition module is used to acquire the photos to be previewed stored in YUV format;

[0122] Among them, the photo acquisition module includes a photo judgment module, which is used to judge whether the photo to be previewed is stored based on the YUV format. If so, it is stored in the storage space; if not, the photo to be previewed is first converted into the YUV format and then stored; a photo reading module is used to obtain the photo to be previewed stored in the storage space based on the YUV format.

[0123] A photo preprocessing module, used for performing image preprocessing on the photo to be previewed to obtain a processed image;

[0124] Among them, the photo preprocessing module includes a photo deinterlacing module, which is used to remove redundant borders and background parts in the photo to be previewed; a photo noise reduction module, which is used to reduce the noise in the photo to be previewed; and a photo adjustment module, which is used to rotate, flip, scale, and crop the photo to be previewed, or a combination of any of several operations to adapt to the output device screen.

[0125] A photo calculation module, used to calculate the processed image using a prediction algorithm to obtain a Y component of image data;

[0126] Among them, the photo calculation module includes a prediction unit establishment module, which is used to establish a prediction unit in the processed image; an average brightness value calculation module, which is used to calculate the average brightness value of all brightness values ​​in each of the prediction units; an image data Y component judgment module, which is used to judge the size relationship between the average brightness value in each of the prediction units and all brightness values, and set the image data Y component according to the size result.

[0127] A photo synthesis module, used for splicing the Y components of the image data to synthesize a complete preview photo;

[0128] Among them, the photo synthesis module includes a memory space allocation module, which is used to allocate a fixed size of memory space according to the photo to be previewed to store the complete preview photo; an image data Y component splicing module, which is used to splice the image data Y component to obtain a complete preview photo.

[0129] The photo output module is used to read the complete preview photo and return the complete preview photo to the user.

[0130] Among them, the photo output module includes a complete preview photo reading module, which is used to obtain the complete preview photo from the storage space; and a photo display module, which is used to adjust the complete preview photo to adapt to the screen of the display device and display it.

[0131] It should be noted that a photo preview device provided in an embodiment of the present invention is used to execute all process steps of a photo preview method in the above embodiment, and the working principles and beneficial effects of the two correspond one to one, so they will not be described in detail.

[0132] The embodiment of the present invention further provides an electronic device. The electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a photo preview program. When the processor executes the computer program, the steps in the above-mentioned photo preview method embodiments are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of the modules / units in the above-mentioned device embodiments are realized, such as the photo synthesis module.

[0133] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the electronic device.

[0134] The electronic device may be a computing device such as a desktop computer, a notebook, a PDA, and a smart tablet. The electronic device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. The electronic device may include more or fewer components than the above components, or may combine certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0135] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device.

[0136] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the electronic device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0137] Wherein, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0138] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0139] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of protection of the present invention.

Claims

1. A photo preview method, characterized in that: include: Get the photo to be previewed stored in YUV format; Performing image preprocessing on the photo to be previewed to obtain a processed image; Using a prediction algorithm to calculate the processed image to obtain a Y component of image data; splicing the Y components of the image data to synthesize a complete preview photo; Reading the complete preview photo and returning the complete preview photo to the user; The step of using a prediction algorithm to calculate the processed image to obtain a Y component of the image data includes: Establishing a prediction unit in the processed image; wherein one prediction unit includes a macroblock, and one macroblock stores a plurality of brightness values; Calculating an average brightness value of each prediction unit according to the brightness values ​​in all the macroblocks in each prediction unit; Determine the magnitude of the brightness value and the average brightness value in each macroblock; if the brightness value is less than the average brightness value, set the Y component of the image data of the current prediction unit to 0; if the brightness value is not less than the average brightness value, calculate the Y component of the image data of the current prediction unit according to the brightness value; Wherein, if the brightness value is not less than the average brightness value, calculating the image data Y component of the current prediction unit according to the brightness value includes: According to the photo to be previewed, a color density offset is obtained; wherein the color density offset includes a blue density offset and a red density offset; Calculating the Y component of the image data of the current prediction unit according to the color density offset; The image data Y component is calculated according to the following formula: ; in, represents the calculated Y component of the image data, Represents the original Y component of the image data, Represents the U component of image data, Represents the image data V component, represents the blue concentration offset, Indicates the red density offset.

2. The photo preview method according to claim 1, characterized in that: The photo to be previewed stored in the YUV format is composed of a number of pixels, and the pixels include an image data Y component, an image data U component and an image data V component; wherein the image data Y component carries the grayscale value information of the image; the image data U component carries the difference information between the blue color and the brightness of the image; and the image data V component carries the difference information between the red color and the brightness of the image.

3. The photo preview method according to claim 1, characterized in that: The step of performing image preprocessing on the photo to be previewed to obtain a processed image includes: Performing an image deinterlacing operation on the photo to be previewed to obtain a photo to be denoised; Performing an image noise reduction operation on the photo to be denoised to obtain the processed image; The image deinterlacing operation includes removing redundant borders and background parts in the photo to be previewed; the image noise reduction operation includes using a filtering algorithm to calculate the photo to reduce noise in the photo; The image denoising operation is performed according to the following formula: ; in, represents a matrix consisting of image pixels, represents the number of rows and columns of the matrix, and The value of is an odd number, Indicates the current row number. Indicates the current column number, Indicates the matrix Row, No. The elements of the column, represents the central element of the matrix.

4. The photo preview method according to claim 1, characterized in that: The step of splicing the Y components of the image data to synthesize a complete preview photo includes: Allocating a fixed-size memory space according to the photos to be previewed; All the Y components of the image data are sequentially read in the memory space and spliced ​​to obtain the complete preview photo.

5. The photo preview method according to claim 4, characterized in that: The step of sequentially reading all Y components of the image data in the memory space and splicing them to obtain the complete preview photo includes: Reading a Y component of the image data; Acquire the position of the Y component of the image data already in the memory space to obtain a splicing position for splicing; The read image data Y component is stored in the splicing position, and the next image data Y component is read, until the end position of the image data Y component is read, to obtain the complete preview photo.

6. A photo preview device, characterized in that: include: The photo acquisition module is used to acquire the photos to be previewed stored in YUV format; A photo preprocessing module, used for performing image preprocessing on the photo to be previewed to obtain a processed image; A photo calculation module, used to calculate the processed image using a prediction algorithm to obtain a Y component of image data; A photo synthesis module, used for splicing the Y components of the image data to synthesize a complete preview photo; A photo output module, used for reading the complete preview photo and returning the complete preview photo to the user; The step of using a prediction algorithm to calculate the processed image to obtain a Y component of the image data includes: Establishing a prediction unit in the processed image; wherein one prediction unit includes a macroblock, and one macroblock stores a plurality of brightness values; Calculating an average brightness value of each prediction unit according to the brightness values ​​in all the macroblocks in each prediction unit; Determine the magnitude of the brightness value and the average brightness value in each macroblock; if the brightness value is less than the average brightness value, set the Y component of the image data of the current prediction unit to 0; if the brightness value is not less than the average brightness value, calculate the Y component of the image data of the current prediction unit according to the brightness value; Wherein, if the brightness value is not less than the average brightness value, calculating the image data Y component of the current prediction unit according to the brightness value includes: According to the photo to be previewed, a color density offset is obtained; wherein the color density offset includes a blue density offset and a red density offset; Calculating the Y component of the image data of the current prediction unit according to the color density offset; The image data Y component is calculated according to the following formula: ; in, represents the calculated Y component of the image data, Represents the original Y component of the image data, Represents the U component of image data, Represents the image data V component, represents the blue concentration offset, Indicates the red density offset.

7. An electronic device, characterized in that: The invention comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the photo preview method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the photo preview method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Color optimization method, terminal and computer readable storage medium

    CN108053453A

  • Brightness balancing method of panoramic looking-around system

    CN113781317A

  • Image compression method, image reconstruction method and related equipment

    CN117119196A

  • RGB image processing method and system

    WO2017190445A1