Website picture automatic display method and device, medium and equipment

Image segmentation and proportional transformation using CNNs address the challenge of resizing images for different website locations, enhancing display quality and efficiency.

CN119089066AInactive Publication Date: 2024-12-06ANRUI DIGITAL INFORMATION TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411138149.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-12-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Images uploaded to different locations on a website often need to be resized, leading to issues such as cropping or compression due to size limitations, resulting in suboptimal display quality.

Method used

A method involving image segmentation using convolutional neural networks (CNN) to separate image elements from the background, followed by proportional transformation and reassembly of sub-images to fit different display sizes, ensuring optimal display quality.

Benefits of technology

Automatically adjusts images to fit various display sizes, improving display quality and saving design time by intelligently cropping and resizing images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119089066A_ABST
    Figure CN119089066A_ABST
Patent Text Reader

Abstract

The invention discloses a website picture automatic display method and device, a medium and equipment. The method comprises the steps that a to-be-displayed picture is read, picture information of the to-be-displayed picture is acquired, and the picture information comprises the height, the width and the number of channels; performing slicing operation on the to-be-displayed picture according to the picture information by using an integer division method to obtain a plurality of sub-images with integer coordinate values and a picture background; according to a new canvas of a display position size of the to-be-displayed picture and a size proportion of an original canvas of the to-be-displayed picture, performing equal-proportion transformation on the plurality of sub-images to obtain a plurality of transformed sub-images of a new size; combining the plurality of transformed sub-images according to a picture background to generate a new-size to-be-displayed picture; and displaying the new-size to-be-displayed picture at the display position.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and more specifically, to a method, device, medium and equipment for automatically displaying website images. Background Art

[0002] When building a website, the images in different locations on the website have different sizes. One image may need to be used in multiple locations. When there is only one image, it is uploaded to different locations on the website. Due to the size limit of the front-end display, the image is either cropped or compressed and stretched. How to upload the same image to locations of different sizes and make the image display beautiful has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] In view of the deficiencies in the prior art, the present invention provides a method, device, medium and equipment for automatically displaying website pictures.

[0004] According to one aspect of the present invention, a method for automatically displaying website pictures is provided, comprising:

[0005] Read the image to be displayed and obtain the image information of the image to be displayed, where the image information includes: height, width and number of channels;

[0006] Use integer division to slice the image to be displayed according to the image information to obtain multiple sub-images and image backgrounds with integer coordinate values;

[0007] According to the size ratio of the new canvas of the display position size of the image to be displayed and the original canvas of the image to be displayed, the multiple sub-images are proportionally transformed to obtain multiple transformed sub-images of new sizes;

[0008] Combining multiple transformed sub-images according to the picture background to generate a new size of the picture to be displayed;

[0009] Display the image of the new size at the display position.

[0010] Optionally, integer division is used to perform a slicing operation on the image to be displayed according to the image information to obtain a plurality of sub-images and an image background having integer coordinate values, including:

[0011] Preprocess the image to be displayed;

[0012] An image segmentation algorithm is used to segment the background and elements of the preprocessed image to be displayed, so as to obtain the image elements and image background of the image to be displayed;

[0013] Performing logical operations pixel by pixel on the binary mask of the image elements and the image to be displayed to extract multiple sub-images;

[0014] Use the binary mask of the image background and the image to be displayed to perform logical operations to extract the image background area.

[0015] Optionally, an image segmentation algorithm is used to segment the background and elements of the preprocessed image to be displayed, and the image elements and the image background of the image to be displayed are obtained, including:

[0016] Prepare a training data set containing positive samples of picture elements and negative samples of picture backgrounds, where the positive samples are image regions containing picture elements and the negative samples are background regions not containing picture elements;

[0017] Design the network structure of CNN and obtain the CNN model, where the CNN model includes convolutional layer, pooling layer, and fully connected layer;

[0018] Preprocess the positive and negative samples in the training data set;

[0019] Use the preprocessed training data set to train the CNN model. Through the back-propagation algorithm, the network parameters of the CNN model are continuously adjusted so that the CNN model can accurately divide the image elements and the image background.

[0020] After training is completed, the validation data set is used to find the best threshold through debugging, and the output result is converted into a binary mask, where the image element area of ​​the image in the binary mask is 1 and the image background area is 0;

[0021] Use the trained CNN model and the determined threshold to segment the input image to be displayed to obtain the image elements and image background of the image to be displayed.

[0022] Optionally, according to the size ratio of the new canvas of the display position size of the image to be displayed and the original canvas of the image to be displayed, the multiple sub-images are proportionally transformed to obtain multiple transformed sub-images of new sizes, including:

[0023] Constructing an affine transformation matrix according to the preset coordinates of multiple points on the image to be displayed and the coordinates of multiple points corresponding to the new canvas;

[0024] The sub-images are proportionally transformed according to the radiation transformation matrix to obtain a plurality of transformed sub-images.

[0025] According to another aspect of the present invention, there is provided a device for automatically displaying website pictures, comprising:

[0026] The first acquisition module is used to read the image to be displayed and obtain the image information of the image to be displayed, wherein the image information includes: height, width and number of channels;

[0027] A second acquisition module is used to perform a slicing operation on the image to be displayed according to the image information by using integer division to obtain a plurality of sub-images with integer coordinate values ​​and an image background;

[0028] A third acquisition module is used to perform proportional transformation on the multiple sub-images according to the size ratio of the new canvas of the display position size of the image to be displayed and the original canvas of the image to be displayed, so as to obtain multiple transformed sub-images of new sizes;

[0029] A generation module, used for combining multiple transformed sub-images according to the picture background to generate a new size of the picture to be displayed;

[0030] The display module is used to display the picture of the new size at the display position.

[0031] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the method described in any one of the above aspects of the present invention.

[0032] According to another aspect of the present invention, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method described in any one of the above aspects of the present invention.

[0033] Therefore, by using the intelligent automatic cropping of images, it is possible to automatically adjust the image elements when the same size image is transmitted to the website to correspond to different size positions, saving image design time. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:

[0035] Figure 1 It is a flowchart of a method for automatically displaying website pictures provided by an exemplary embodiment of the present invention;

[0036] Figure 2 It is a structural schematic diagram of a device for automatically displaying website pictures provided by an exemplary embodiment of the present invention;

[0037] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0038] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.

[0039] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.

[0040] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present invention are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.

[0041] It should also be understood that, in the embodiments of the present invention, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.

[0042] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.

[0043] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.

[0044] It should also be understood that the description of the various embodiments of the present invention focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.

[0045] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0046] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.

[0047] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0048] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0049] Embodiments of the present invention can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.

[0050] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.

[0051] Exemplary Methods

[0052] Figure 1 FIG. 1 is a flow chart of a method for automatically displaying website images provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the website picture automatic display method 100 includes the following steps:

[0053] Step 101, read the picture to be displayed, and obtain the picture information of the picture to be displayed, wherein the picture information includes: height, width and number of channels;

[0054] Step 102, using integer division to perform a slicing operation on the image to be displayed according to the image information, to obtain a plurality of sub-images with integer coordinate values ​​and an image background;

[0055] Step 103, according to the size ratio of the new canvas of the display position size of the image to be displayed and the original canvas of the image to be displayed, multiple sub-images are proportionally transformed to obtain multiple transformed sub-images of new sizes;

[0056] Step 104, combining multiple transformed sub-images according to the picture background to generate a new size of the picture to be displayed;

[0057] Step 105: Display the image to be displayed with the new size at the display position.

[0058] Specifically, in response to the problems existing in the background technology, the present invention uses the background color of the picture as a canvas. When the picture is uploaded, the content in the picture is automatically split into various elements, and then the center point of each element is located, and the elements are proportionally scaled according to the minimum value of the canvas scaling ratio, and then the elements are re-joined on the canvas. The specific implementation process is as follows:

[0059] 1. First, use OpenCV's `imread` function to read the image.

[0060] 2. Then, use the `shape` attribute to get the height, width, and number of channels of the image.

[0061] 3. Next, use the slicing operation to split the image into multiple sub-images. Use integer division (` / / `) to ensure that the divided sub-images have integer coordinate values.

[0062] Among them, the image segmentation method is used to extract each element in the picture, as follows:

[0063] (1) Preprocessing: Preprocess the original image, such as grayscale or color space conversion, for better processing.

[0064] (2) Use appropriate image segmentation methods (such as threshold segmentation, edge detection, etc.) to distinguish the elements in the image from the background. This can be achieved by selecting an appropriate threshold detection algorithm - convolutional neural network. This will generate a binary mask in which the element area in the image is marked as foreground (white) and the background area is marked as background (black).

[0065] Convolutional Neural Networks:

[0066] [1]. Data preparation: Prepare a training dataset containing positive samples (target elements) and negative samples (background). Positive samples should be image regions containing target elements, while negative samples should be background regions that do not contain target elements.

[0067] [2]. Network architecture design: Design the network structure of CNN, which may include convolutional layers, pooling layers, fully connected layers, etc.

[0068] [3]. Data preprocessing: Preprocess the images in the training dataset, such as normalization, resizing, etc.

[0069] [4]. Model training: Use the prepared training data set to train the CNN model. Through the back-propagation algorithm, the network parameters are continuously adjusted so that the network can accurately distinguish the target elements and the background.

[0070] [5]. Threshold determination: After training is completed, the validation dataset can be used to find the best threshold through debugging and convert the output result into a binary mask, where the element area in the image is the foreground (1) and the background area is the background (0).

[0071] [6]. Image segmentation: Using the trained CNN model and the determined threshold, the input image can be segmented to separate the image elements from the background.

[0072] (3) Sub-image extraction: According to the binary mask of the extracted image elements, the corresponding area in the original image is extracted to form multiple sub-images. The mask can be used to perform pixel-by-pixel logical operations with the original image to extract the foreground area.

[0073] (4) Background extraction: Conversely, the background binary mask can be used to perform logical operations with the original image to extract the background area.

[0074] 4. Write the size of the image at the current position in the code and use the size as the new canvas.

[0075] Among them, you can write the size of the image at the current position in the code and use the size as the new canvas; for example, use the image segmentation algorithm and threshold-based segmentation:

[0076] (a) Python

[0077] #Convert the image to grayscale

[0078] gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)

[0079] #Get the binary image of the image through threshold segmentation

[0080] ret,threshold=cv2.threshold(gray,127,255,cv2.THRESH_BINARY)

[0081] (b) Get the outline of the element:

[0082] By finding the contours in the binary image, the boundaries of the elements can be obtained.

[0083] Python

[0084] contours,hierarchy=cv2.findContours(threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

[0085] (c) Traverse the contour and obtain the positioning coordinates:

[0086] Python

[0087] for contour in contours:

[0088] #Get the bounding rectangle of the contour

[0089] x,y,w,h=cv2.boundingRect(contour)

[0090] #Draw a rectangular frame on the original image

[0091] cv2.rectangle(image,(x,y),(x+w,y+h),(0,0,255),2)

[0092] #Print positioning coordinates

[0093] print("element location coordinates:",x,y,x+w,y+h)

[0094] In the above steps, the image is first converted to a grayscale image, and then a binary image is obtained by threshold segmentation. After that, the findContours function is used to find the contours in the binary image, and the boundingRect function is used to obtain the coordinates of the circumscribed rectangle of each contour. Finally, a rectangular frame can be drawn on the original image and the positioning coordinates can be printed.

[0095] 5. Then calculate the size ratio of the new canvas and the original canvas, use the coordinates with the larger change as the size basis, and then reduce or enlarge the sub-image proportionally according to this ratio.

[0096] 6. Then, use the `vconcat` and `hconcat` functions to recombine the sub-images vertically and horizontally on the new canvas to form a picture of a new size.

[0097] The sub-images are reassembled vertically and horizontally on the new canvas to form a picture of a new size.

[0098] Specific method: Define an affine transformation matrix and use the `warpAffine` function of the OpenCV library to perform an affine transformation on the image:

[0099]

[0100] Among them, a and d represent scaling factors, b and c represent shear factors in the x and y directions, and tx and ty represent translation amounts.

[0101] In OpenCV, you can use the `cv2.getAffineTransform()` function to get the affine transformation matrix. This function needs to pass in the coordinates of three points on the original image and the corresponding three points on the target image, and then returns a 2x3 affine transformation matrix.

[0102] In the above method, the image is first read, and the coordinates of three points on the original image and the corresponding three points on the target image are defined. Then, the `cv2.getAffineTransform()` function is used to obtain the affine transformation matrix M. Finally, the `warpAffine` function is used to perform an affine transformation on the image and the result is displayed.

[0103] 7. Finally, use the `imshow` function to display the original image and the split and reassembled image.

[0104] Therefore, by using the intelligent automatic cropping of images, it is possible to automatically adjust the image elements when the same size image is transmitted to the website to correspond to different size positions, saving image design time.

[0105] Exemplary Devices

[0106] Figure 2 Schematic diagram of the structure of a website picture automatic display device provided by an exemplary embodiment of the present invention. Figure 2 As shown, the device 200 includes:

[0107] The first acquisition module 210 is used to read the image to be displayed and obtain the image information of the image to be displayed, wherein the image information includes: height, width and number of channels;

[0108] The second acquisition module 220 is used to perform a slicing operation on the image to be displayed according to the image information by using integer division to obtain a plurality of sub-images with integer coordinate values ​​and an image background;

[0109] The third acquisition module 230 is used to perform proportional transformation on the multiple sub-images according to the size ratio of the new canvas of the display position size of the image to be displayed and the original canvas of the image to be displayed, so as to obtain multiple transformed sub-images of new sizes;

[0110] A generating module 240, used to combine a plurality of transformed sub-images according to the picture background to generate a picture of a new size to be displayed;

[0111] The display module 250 is used to display the picture with a new size at the display position.

[0112] Optionally, the second acquisition module 220 includes:

[0113] A preprocessing submodule, used to preprocess the image to be displayed;

[0114] The first acquisition submodule is used to segment the background and elements of the pre-processed image to be displayed by using an image segmentation algorithm to obtain the image elements and image background of the image to be displayed;

[0115] A first extraction submodule is used to perform a logical operation on the binary mask of the picture element and the picture to be displayed pixel by pixel to extract a plurality of sub-images;

[0116] The second extraction submodule is used to perform a logic operation using the binary mask of the picture background and the picture to be displayed to extract the picture background area.

[0117] Optionally, the first acquisition submodule includes:

[0118] A preparation unit, used to prepare a training data set containing positive samples of picture elements and negative samples of picture backgrounds, wherein the positive samples are image regions containing picture elements and the negative samples are background regions not containing picture elements;

[0119] A design unit, used to design the network structure of CNN and obtain the CNN model, wherein the CNN model includes a convolutional layer, a pooling layer, and a fully connected layer;

[0120] A preprocessing unit, used to preprocess positive samples and negative samples in the training data set;

[0121] The training unit is used to train the CNN model using the preprocessed training data set, and continuously adjust the network parameters of the CNN model through the back propagation algorithm, so that the CNN model can accurately divide the image elements and the image background;

[0122] The debugging unit is used to find the best threshold through debugging using the validation data set after training is completed, and convert the output result into a binary mask, where the image element area of ​​the image in the binary mask is 1 and the image background area is 0;

[0123] The segmentation unit is used to segment the input image to be displayed using the trained CNN model and the determined threshold value, and obtain the image elements and image background of the image to be displayed.

[0124] Optionally, the third acquisition module 230 includes:

[0125] A construction submodule, used to construct an affine transformation matrix according to a plurality of point coordinates preset on the image to be displayed and a plurality of point coordinates corresponding to the new canvas;

[0126] The second acquisition submodule is used to perform proportional transformation on the sub-image according to the radiation transformation matrix to obtain a plurality of transformed sub-images.

[0127] Exemplary Electronic Devices

[0128] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. Figure 3 As shown, the electronic device 30 includes one or more processors 31 and a memory 32 .

[0129] The processor 31 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.

[0130] The memory 32 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 31 may run the program instructions to implement the methods of the software programs of the various embodiments of the present invention described above and / or other desired functions. In one example, the electronic device may also include: an input device 33 and an output device 34, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0131] In addition, the input device 33 may also include, for example, a keyboard, a mouse, and the like.

[0132] The output device 34 can output various information to the outside. The output device 34 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.

[0133] Of course, to simplify, Figure 3 Only some of the components related to the present invention in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device may also include any other appropriate components.

[0134] Exemplary computer program products and computer-readable storage media

[0135] In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method according to various embodiments of the present invention described in the above-mentioned "Exemplary Method" section of this specification.

[0136] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0137] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enable the processor to execute the steps of the method for information mining of historical change records according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0138] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, system or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0139] The basic principle of the present invention is described above in conjunction with specific embodiments. However, it should be pointed out that the advantages, strengths, effects, etc. mentioned in the present invention are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. must be possessed by each embodiment of the present invention. In addition, the specific details disclosed above are only for the purpose of illustration and facilitation of understanding, rather than limitation, and the above details do not limit the present invention to being implemented by adopting the above specific details.

[0140] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0141] The block diagrams of the devices, systems, equipment, and systems involved in the present invention are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, systems, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The word "such as" used here refers to the phrase "such as but not limited to", and can be used interchangeably with it.

[0142] The method and system of the present invention may be implemented in many ways. For example, the method and system of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware, firmware. The above order of steps for the method is only for illustration, and the steps of the method of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present invention may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.

[0143] It should also be noted that in the system, device and method of the present invention, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present invention. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined here can be applied to other aspects without departing from the scope of the present invention. Therefore, the present invention is not intended to be limited to the aspects shown here, but in accordance with the widest range consistent with the principles and novel features disclosed here.

[0144] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present invention to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A method for automatically displaying website pictures, characterized in that: include: Read the image to be displayed, and obtain the image information of the image to be displayed, wherein the image information includes: height, width and number of channels; Using integer division to perform a slicing operation on the image to be displayed according to the image information, to obtain a plurality of sub-images with integer coordinate values ​​and an image background; According to the size ratio of the new canvas of the display position size of the picture to be displayed and the original canvas of the picture to be displayed, the plurality of sub-images are proportionally transformed to obtain a plurality of transformed sub-images of new sizes; Combining the plurality of transformed sub-images according to the picture background to generate a picture of a new size to be displayed; The picture to be displayed with the new size is displayed at the display position.

2. The method according to claim 1, characterized in that: Using integer division to slice the image to be displayed according to the image information to obtain a plurality of sub-images with integer coordinate values ​​and an image background, including: Preprocessing the picture to be displayed; Using an image segmentation algorithm to segment the background and elements of the preprocessed image to be displayed, and obtaining the image elements and image background of the image to be displayed; Performing a logical operation pixel by pixel on the binary mask of the picture element and the picture to be displayed to extract a plurality of sub-images; A binary mask of the picture background and the picture to be displayed are used to perform a logical operation to extract the picture background area.

3. The method according to claim 2, characterized in that The image segmentation algorithm is used to segment the background and elements of the preprocessed image to be displayed, and the image elements and the image background of the image to be displayed are obtained, including: Prepare a training data set containing positive samples of picture elements and negative samples of picture backgrounds, wherein the positive samples are image regions containing picture elements, and the negative samples are background regions not containing picture elements; Designing a CNN network structure and obtaining a CNN model, wherein the CNN model includes a convolutional layer, a pooling layer, and a fully connected layer; Preprocessing the positive samples and the negative samples in the training data set; The CNN model is trained using the preprocessed training data set, and the network parameters of the CNN model are continuously adjusted through a back propagation algorithm so that the CNN model can accurately separate the image elements and the image background; After the training is completed, the validation data set is used to find the best threshold through debugging, and the output result is converted into a binary mask, where the image element area of ​​the image in the binary mask is 1 and the image background area is 0; Using the trained CNN model and the determined threshold, the input image to be displayed is segmented to obtain the image elements and image background of the image to be displayed.

4. The method according to claim 1, characterized in that According to the new canvas of the display position size of the picture to be displayed and the size ratio of the original canvas of the picture to be displayed, the multiple sub-images are proportionally transformed to obtain multiple transformed sub-images of new sizes, including: Constructing an affine transformation matrix according to a plurality of point coordinates preset on the image to be displayed and a plurality of point coordinates corresponding to the new canvas; The sub-image is proportionally transformed according to the radiation transformation matrix to obtain a plurality of transformed sub-images.

5. A website picture automatic display device, characterized in that: include: A first acquisition module is used to read the image to be displayed and acquire the image information of the image to be displayed, wherein the image information includes: height, width and number of channels; A second acquisition module is used to perform a slicing operation on the to-be-displayed picture according to the picture information by using integer division to obtain a plurality of sub-images with integer coordinate values ​​and a picture background; A third acquisition module is used to perform proportional transformation on the multiple sub-images according to the size ratio of the new canvas of the display position size of the picture to be displayed and the original canvas of the picture to be displayed, so as to obtain multiple transformed sub-images of new sizes; A generating module, used for combining the plurality of transformed sub-images according to the picture background to generate a picture of a new size to be displayed; A display module is used to display the picture of the new size to be displayed at the display position.

6. The device according to claim 5, characterized in that The second acquisition module includes: A preprocessing submodule, used for preprocessing the image to be displayed; A first acquisition submodule is used to segment the background and elements of the pre-processed image to be displayed by using an image segmentation algorithm to obtain the image elements and image background of the image to be displayed; A first extraction submodule, configured to perform a logical operation pixel by pixel on the binary mask of the picture element and the picture to be displayed to extract a plurality of sub-images; The second extraction submodule is used to perform a logic operation using the binary mask of the picture background and the picture to be displayed to extract the picture background area.

7. The device according to claim 6, characterized in that The first acquisition submodule includes: A preparation unit, used to prepare a training data set including positive samples of picture elements and negative samples of picture backgrounds, wherein the positive samples are image regions containing picture elements, and the negative samples are background regions not containing picture elements; A design unit, used to design a CNN network structure and obtain a CNN model, wherein the CNN model includes a convolutional layer, a pooling layer, and a fully connected layer; A preprocessing unit, used for preprocessing the positive samples and the negative samples in the training data set; A training unit, used to train the CNN model using the preprocessed training data set, and continuously adjust the network parameters of the CNN model through a back propagation algorithm, so that the CNN model can accurately divide the image elements and the image background; A debugging unit, used to find the best threshold value through debugging using the verification data set after the training is completed, and convert the output result into a binary mask, wherein the image element area of ​​the image in the binary mask is 1 and the image background area is 0; The segmentation unit is used to segment the input image to be displayed by using the trained CNN model and the determined threshold value, and obtain the image elements and image background of the image to be displayed.

8. The device according to claim 5, characterized in that The third acquisition module includes: A construction submodule, used to construct an affine transformation matrix according to a plurality of point coordinates preset on the image to be displayed and a plurality of point coordinates corresponding to the new canvas; The second acquisition submodule is used to perform proportional transformation on the sub-image according to the radiation transformation matrix to obtain a plurality of transformed sub-images.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 4.

10. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the method described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Picture generation method and device, electronic equipment and readable storage medium

    CN112164127A

  • Image display method and device, electronic equipment and storage medium

    CN112532785A

  • Image segmentation method and device, electronic equipment and storage medium

    CN115482248A

  • Real-time AI image background dynamic generation method, medium and system

    CN118097076A

  • Image segmentation method and device based on threshold processing, electronic equipment and storage medium

    CN118470056A