CN108921792A - Method and apparatus for handling picture - Google Patents

Method and apparatus for handling picture Download PDF

Info

Publication number
CN108921792A
CN108921792A CN201810714637.5A CN201810714637A CN108921792A CN 108921792 A CN108921792 A CN 108921792A CN 201810714637 A CN201810714637 A CN 201810714637A CN 108921792 A CN108921792 A CN 108921792A
Authority
CN
China
Prior art keywords
picture
processed
size
standard size
pixels
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810714637.5A
Other languages
Chinese (zh)
Other versions
CN108921792B (en
Inventor
徐珍琦
王长虎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201810714637.5A priority Critical patent/CN108921792B/en
Priority to PCT/CN2018/116336 priority patent/WO2020006962A1/en
Publication of CN108921792A publication Critical patent/CN108921792A/en
Application granted granted Critical
Publication of CN108921792B publication Critical patent/CN108921792B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The embodiment of the present application discloses the method and apparatus for handling picture.One specific embodiment of this method includes:Obtain picture to be processed;Standard size corresponding with picture to be processed is chosen from preset standard size set as target size;Picture to be processed by the size adjusting of picture to be processed to target size, after being adjusted;Picture to be processed adjusted is input to picture trained in advance and handles model, obtains processing result.The embodiment helps to be promoted flexibility when adjustment dimension of picture.

Description

Method and apparatus for handling picture
Technical field
The invention relates to field of computer technology, and in particular to the method and apparatus for handling picture.
Background technique
It is also more and more extensive in the application of picture process field with the development of artificial neural network.For example, in picture Corresponding neural network model can be used to handle picture in the fields such as identification, picture classification.
In the prior art, some processes using neural network model processing picture are usually first by picture to be processed Then size scaling is again handled picture to a standard size.Also, when the quantity of picture to be processed is multiple, Usually by the size scaling of each picture to be processed to the same standard size.
Summary of the invention
The embodiment of the present application proposes the method and apparatus for handling picture.
In a first aspect, the embodiment of the present application provides a kind of method for handling picture, this method includes:It obtains wait locate Manage picture;Standard size corresponding with picture to be processed is chosen from preset standard size set as target size;It will be to Handle to be processed picture of the size adjusting of picture to target size, after being adjusted;Picture to be processed adjusted is inputted Model is handled to picture trained in advance, obtains processing result.
In some embodiments, standard size corresponding with picture to be processed is chosen from preset standard size set to make For target size, including:Determine the size of picture to be processed;Based on the size of picture to be processed, from preset standard size collection Standard size corresponding with picture to be processed is chosen in conjunction as target size.
In some embodiments, the size based on picture to be processed is chosen from preset standard size set and to from The corresponding standard size of picture is managed as target size, including:Choose the smallest standard of difference with the size of picture to be processed Size is as target size.
In some embodiments, the size of picture to be processed is the resolution ratio of picture to be processed, the resolution of picture to be processed Rate is indicated with Horizontal number of pixels and Vertical number of pixels;And for the standard size in standard size set, the standard size with The difference of the size of picture to be processed determines as follows:Determine the Horizontal number of pixels and Vertical number of pixels of picture to be processed Ratio;Determine the ratio of the standard size corresponding Horizontal number of pixels and Vertical number of pixels;By the horizontal picture of picture to be processed The difference of the ratio of the ratio of prime number and Vertical number of pixels Horizontal number of pixels corresponding with the standard size and Vertical number of pixels it is exhausted Difference to value as the standard size and the size of picture to be processed.
In some embodiments, standard size corresponding with picture to be processed is chosen from preset standard size set to make For target size, including:Determine the content information of picture to be processed;According to the content information pre-established with it is standard-sized right It should be related to, determine standard size corresponding with the highest content information of the similarity of the content information of picture to be processed as target Size.
In some embodiments, training obtains picture processing model as follows:Training sample set is obtained, In, training sample includes the processing result of samples pictures and samples pictures;For the training sample in training sample set, from mark Choose standard size corresponding with the samples pictures in the training sample in object staff cun set, and by the sample in the training sample Samples pictures of the size adjusting of this picture to selected standard size, after being adjusted;It, will using the method for machine learning The corresponding samples pictures adjusted of samples pictures in training sample in training sample set as input, by with input For the corresponding processing result of samples pictures adjusted as desired output, training obtains picture processing model.
Second aspect, the embodiment of the present application provide a kind of for handling the device of picture, which includes:It obtains single Member is configured to obtain picture to be processed;Selection unit, be configured to from preset standard size set choose with it is to be processed The corresponding standard size of picture is as target size;Adjustment unit is configured to the size adjusting of picture to be processed to target Size, the picture to be processed after being adjusted;Processing unit is configured to picture to be processed adjusted being input to preparatory instruction Experienced picture handles model, obtains processing result.
In some embodiments, above-mentioned selection unit is further configured to:Determine the size of picture to be processed;Based on to The size for handling picture chooses standard size corresponding with picture to be processed as target ruler from preset standard size set It is very little.
In some embodiments, above-mentioned selection unit is further configured to:Choose the difference with the size of picture to be processed It is worth the smallest standard size as target size.
In some embodiments, the size of picture to be processed is the resolution ratio of picture to be processed, the resolution of picture to be processed Rate is indicated with Horizontal number of pixels and Vertical number of pixels;And for the standard size in standard size set, the standard size with The difference of the size of picture to be processed determines as follows:Determine the Horizontal number of pixels and Vertical number of pixels of picture to be processed Ratio;Determine the ratio of the standard size corresponding Horizontal number of pixels and Vertical number of pixels;By the horizontal picture of picture to be processed The difference of the ratio of the ratio of prime number and Vertical number of pixels Horizontal number of pixels corresponding with the standard size and Vertical number of pixels it is exhausted Difference to value as the standard size and the size of picture to be processed.
In some embodiments, above-mentioned selection unit is further configured to:Determine the content information of picture to be processed;Root According to the content information and standard-sized corresponding relationship pre-established, the similarity of determining and picture to be processed content information is most The corresponding standard size of high content information is as target size.
In some embodiments, training obtains picture processing model as follows:Training sample set is obtained, In, training sample includes the processing result of samples pictures and samples pictures;For the training sample in training sample set, from mark Choose standard size corresponding with the samples pictures in the training sample in object staff cun set, and by the sample in the training sample Samples pictures of the size adjusting of this picture to selected standard size, after being adjusted;It, will using the method for machine learning The corresponding samples pictures adjusted of samples pictures in training sample in training sample set as input, by with input For the corresponding processing result of samples pictures adjusted as desired output, training obtains picture processing model.
The third aspect, the embodiment of the present application provide a kind of electronic equipment, which includes:One or more processing Device;Storage device, for storing one or more programs;When one or more programs are executed by one or more processors, make Obtain method of the one or more processors realization as described in implementation any in first aspect.
Fourth aspect, the embodiment of the present application provide a kind of computer-readable medium, are stored thereon with computer program, should The method as described in implementation any in first aspect is realized when computer program is executed by processor.
Method and apparatus provided by the embodiments of the present application for handling picture, by obtaining picture to be processed, from default Standard size set in choose corresponding with picture to be processed standard size as target size.Then, by picture to be processed Size adjusting to the target size chosen, and picture adjusted input picture trained in advance is handled into model, obtained everywhere Reason is as a result, to can be according to specifically wait locate when adjusting the size of picture to be processed by preset multiple standards size Picture is managed, by the size adjusting of picture to be processed to corresponding standard size, when helping to improve dimension of picture adjustment Flexibility.
Detailed description of the invention
By reading a detailed description of non-restrictive embodiments in the light of the attached drawings below, the application's is other Feature, objects and advantages will become more apparent upon:
Fig. 1 is that one embodiment of the application can be applied to exemplary system architecture figure therein;
Fig. 2 is the flow chart of one embodiment of the method for handling picture of the application;
Fig. 3 is the flow chart according to another embodiment of the method for handling picture of the application;
Fig. 4 is the schematic diagram according to an application scenarios of the method for handling picture of the application;
Fig. 5 is the structural schematic diagram according to one embodiment of the device for handling picture of the application;
Fig. 6 is adapted for the structural schematic diagram for the computer system for realizing the electronic equipment of the embodiment of the present application.
Specific embodiment
The application is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining related invention, rather than the restriction to the invention.It also should be noted that in order to Convenient for description, part relevant to related invention is illustrated only in attached drawing.
It should be noted that in the absence of conflict, the features in the embodiments and the embodiments of the present application can phase Mutually combination.The application is described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
Fig. 1 shows one of the method for handling picture or the device for handling picture that can apply the application The exemplary architecture 100 of embodiment.
As shown in Figure 1, system architecture 100 may include terminal device 101,102,103, network 104 and server 105. Network 104 between terminal device 101,102,103 and server 105 to provide the medium of communication link.Network 104 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
Terminal device 101,102,103 is interacted by network 104 with server 105, to receive or send message etc..Terminal Various client applications can be installed, such as web browser applications, picture handle class application in equipment 101,102,103 Deng.
Terminal device 101,102,103 can be hardware, be also possible to software.When terminal device 101,102,103 is hard When part, it can be the various electronic equipments for being capable of handling picture, including but not limited to smart phone, tablet computer, e-book is read Read device, pocket computer on knee and desktop computer etc..When terminal device 101,102,103 is software, can install In above-mentioned cited electronic equipment.Multiple softwares or software module may be implemented into (such as providing distributed clothes in it The multiple softwares or software module of business), single software or software module also may be implemented into.It is not specifically limited herein.
Server 105 can be to provide the server of various services, for example, on terminal device 101,102,103 wait locate It manages picture and the picture processing server of analysis processing is provided.Picture processing server can carry out size adjusting to picture to be processed Deng processing, and processing result is generated, processing result (picture to be processed after such as size adjusting) can also be fed back to terminal and set It is standby.
It should be noted that above-mentioned picture to be processed can also be stored directly in the local of server 105, server 105 The local picture to be processed stored can directly be extracted and handled, at this point it is possible to there is no terminal device 101,102, 103 and network 104.
It should be noted that generally executed by server 105 provided by the embodiment of the present application for handling picture approach, Correspondingly, it is generally positioned in server 105 for handling the device of picture.
It may also be noted that can also be equipped with picture processing class application in terminal device 101,102,103, terminal is set Standby 101,102,103 can also be based on picture processing class using handling picture to be processed, at this point, for handling picture Method can also be executed by terminal device 101,102,103, and correspondingly, the device for handling picture also can be set in terminal In equipment 101,102,103.At this point, server 105 and network 104 can be not present in exemplary system architecture 100.
It should be noted that server can be hardware, it is also possible to software.When server is hardware, may be implemented At the distributed server cluster that multiple servers form, individual server also may be implemented into.It, can when server is software It, can also be with to be implemented as multiple softwares or software module (such as providing multiple softwares of Distributed Services or software module) It is implemented as single software or software module.It is not specifically limited herein.
It should be understood that the number of terminal device, network and server in Fig. 1 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
With continued reference to Fig. 2, the process of one embodiment of the method for handling picture according to the application is shown 200.The method for being used to handle picture includes the following steps:
Step 201, picture to be processed is obtained.
In the present embodiment, can lead to for handling the executing subject (server 105 as shown in Figure 1) of the method for picture Wired or wireless mode is crossed to obtain from local or other storage equipment (terminal device 101,102,103 as shown in Figure 1) Picture to be processed.Wherein, picture to be processed can be any type of picture.
Step 202, standard size corresponding with picture to be processed is chosen from preset standard size set as target Size.
In the present embodiment, size can refer to the physical size of picture, such as the length and width of picture.Size can also refer to The resolution ratio of picture.Size can also refer to the size of picture, the memory space occupied such as picture.Standard size can be preset Arbitrary dimension.According to different application demands, different standard size set can be preset.
Wherein, picture to be processed can have different corresponding relationships according to different counterlogics from standard size.It is different Corresponding relationship usually can use different selection modes, selection standard size is as mesh from preset standard size set Dimensioning.
In some optional implementations of the present embodiment, it can first determine the size of picture to be processed, be then based on The size of determining picture to be processed, selection standard size is as target size from preset standard size set.
It is alternatively possible to which the size of picture is divided into several types in advance.For example, the size of picture can be divided Be length-width ratio be greater than 1, length-width ratio be equal to 1 and length-width ratio less than 1 these three types.Then, it for each type of size, determines The corresponding standard size of the size of this type.At this point it is possible to according to the size of picture to be processed, directly from preset gauge The corresponding standard size of size of picture to be processed is chosen in very little set as target size.
Specifically, for each type of size, the picture of the size of a large amount of the type can be obtained in advance, then, For a large amount of pictures of acquisition, calculate the size adjusting of these pictures to one of preset standard size set gauge The average value of loss of significance after very little.Similarly, determine the size adjusting by these pictures into preset standard size set Other each standard sizes after corresponding loss of significance average value.Then, being averaged for the smallest loss of significance is selected It is worth picture corresponding standard size of the corresponding standard size as the size of the type.
In some optional implementations of the present embodiment, the content information of picture to be processed can be first determined, then According to the content information of the picture pre-established and standard-sized corresponding relationship, by the phase of the content information with picture to be processed The standard size like corresponding to degree highest content information is as target size.
Wherein, content information can be information relevant to the content of picture to be processed.Such as content information can be to Type, the number for the object for including of object etc. for including in processing picture.Specifically, existing various picture inspections be can use It surveys or recognition methods determines the content information of picture to be processed.For example, can use existing various for picture classification Deep learning model (such as AlexNet) classifies to picture to be processed, and the picture to be processed that will be determined in classification results Content information of the label as picture to be processed.For example, it is also possible to using existing some picture classification softwares, and will classification Content information of the theme for the picture to be processed that software determines as picture to be processed.For example, it is also possible to using existing various Picture understanding method (the image text description such as based on Multimodal Recurrent Neural Network) is to be processed Picture is handled, using the text of obtained description image as the content information of picture to be processed.
For example, for picture recognition class application, the content information and gauge for being stored with picture can be pre-established The mapping table of very little corresponding relationship.For example, can correspond to length-width ratio is 5 for face class picture:3 standard size, For automotive-type picture, can correspond to length-width ratio is 3:1 standard size.At this point, in the content letter for determining picture to be processed When breath is face, then 5 can be chosen:3 standard size is automobile in the content information of picture to be processed as target size When, then 3 can be chosen:1 standard size is as target size.
It, can also be as follows from preset standard size collection in some optional implementations of the present embodiment Standard size corresponding with picture to be processed is chosen in conjunction as target size:
The size of picture to be processed is separately adjusted to angularly each standard size in standard size set by the first step, thus Picture set to be processed after being adjusted.
Second step calculates separately each of picture set to be processed adjusted picture to be processed adjusted and obtains Picture to be processed similarity, to obtain similarity set.
Third step, chooses maximum similarity from obtained similarity set, and by the maximum similarity pair of selection The standard size answered is as target size.
Step 203, the picture to be processed by the size adjusting of picture to be processed to target size, after being adjusted.
In the present embodiment, it can use the various applications for handling picture to adjust the size of picture to be processed It is whole, thus the picture to be processed by the size adjusting of picture to be processed to the target size chosen, after obtaining size adjusting.
Step 204, picture to be processed adjusted is input to picture trained in advance and handles model, obtain processing knot Fruit.
In the present embodiment, picture processing model can be the various models for being capable of handling picture.For example, picture handles mould Type can be the various deep learning models for being capable of handling picture.Picture processing model is also possible to the various pictures of being capable of handling Convolutional neural networks.Various processing modes can be to the processing of picture.Such as the denoising of picture classification, picture recognition, picture, figure Piece reduction etc..
In some optional implementations of the present embodiment, picture handles model can be trained as follows It arrives:
The first step obtains training sample set, wherein training sample includes the processing knot of samples pictures and samples pictures Fruit.
Second step is chosen and the training sample from standard size set for the training sample in training sample set In the corresponding standard size of samples pictures, and by the size adjusting of the samples pictures in the training sample to selected standard Size, the samples pictures after being adjusted.
Specifically, can according to the methods of the various selection standard sizes illustrated in above-mentioned steps 202 in the present embodiment from The corresponding standard size of samples pictures in each sample is chosen in standard size set.
Third step, it is using the method for machine learning, the samples pictures in the training sample in training sample set are corresponding Samples pictures adjusted as input, using processing result corresponding with the samples pictures adjusted of input as expectation it is defeated Out, training obtains above-mentioned being capable of handling various standard-sized pictures processing models.
Specifically, third step can be achieved by the steps of:
Firstly, obtaining initial picture handles model.Wherein, initial picture processing model can be various types of without instruction Practice or do not train the artificial neural network completed.Such as deep learning model.Initial picture processing model is also possible to a variety of The model that artificial neural network unbred or that training is not completed is combined.For example, initial picture handles model It can be and unbred convolutional neural networks, unbred Recognition with Recurrent Neural Network and unbred full articulamentum are carried out Combine obtained model.Initial picture processing model can also be at more existing trained completion, open source picture Manage model.Initial picture processing model is also possible to utilize existing various neural network API (Application Programming Interface, application programming interface) neural network that constructs.
It is then possible to which the corresponding samples pictures adjusted of samples pictures in each training sample are as above-mentioned initial graph Piece handles the input of model, and output and preset loss function based on initial picture processing model handle model to initial picture It is trained, and the initial picture processing model after the completion of training is handled into model as picture.
Wherein, the value of above-mentioned loss function can be used to characterize the processing of initial picture processing model output in training process As a result the difference degree of processing result corresponding with the samples pictures adjusted of input.Loss function is smaller, indicates that difference is got over It is small.And it is possible to be determined whether to train completion according to loss function.For example, can be by the loss function of front and back twice or repeatedly Value be respectively less than certain threshold value as termination condition.At this point, the value of the loss function before and after determination twice or repeatedly is respectively less than When certain threshold value, then training is completed, and the picture that the initial picture processing model after the completion of training is completed as training is handled mould Type.
It, can be for each mark in preset standard size set in some optional implementations of the present embodiment Object staff cun trains the corresponding picture processing model of the standard size in advance.At this point, after the picture to be processed after being adjusted, The picture that can first train according to corresponding to target size selection target size, in advance handles model.Then selection is utilized Picture processing model handles picture to be processed adjusted.Specifically, for every in preset standard size set A standard size, the corresponding picture processing model of the standard size can train as follows to be obtained:
The first step obtains training sample set, wherein training sample may include the processing of samples pictures and samples pictures As a result.
Second step, for each training sample in training sample set, by the ruler of the samples pictures in the training sample It is very little to adjust to the standard size, the samples pictures after being adjusted.
Third step, it is using the method for machine learning, the samples pictures in the training sample in training sample set are corresponding Samples pictures adjusted as input, using processing result corresponding with the samples pictures adjusted of input as expectation it is defeated Out, training obtains the corresponding picture processing model of the standard size.
Above-mentioned third step can be realized especially by following steps:
Firstly, obtaining initial picture handles model.Wherein, initial picture processing model can be various types of without instruction Practice or do not train the artificial neural network completed.Such as deep learning model.Initial picture processing model is also possible to a variety of The model that artificial neural network unbred or that training is not completed is combined.For example, initial picture handles model It can be and unbred convolutional neural networks, unbred Recognition with Recurrent Neural Network and unbred full articulamentum are carried out Combine obtained model.Initial picture processing model can also be at more existing trained completion, open source picture Manage model.Initial picture processing model is also possible to utilize existing various neural network API (Application Programming Interface, application programming interface) neural network that constructs.
It is then possible to which the corresponding samples pictures adjusted of samples pictures in each training sample are as above-mentioned initial graph Piece handles the input of model, and output and preset loss function based on initial picture processing model handle model to initial picture It is trained, and the initial picture processing model after the completion of training is handled into model as picture.
Wherein, the value of above-mentioned loss function can be used to characterize the processing of initial picture processing model output in training process As a result the difference degree of processing result corresponding with the samples pictures adjusted of input.Loss function is smaller, indicates that difference is got over It is small.And it is possible to be determined whether to train completion according to loss function.For example, can be by the loss function of front and back twice or repeatedly Value be respectively less than certain threshold value as termination condition.At this point, the value of the loss function before and after determination twice or repeatedly is respectively less than When certain threshold value, then training is completed, and the picture that the initial picture processing model after the completion of training is completed as training is handled mould Type.
In some optional implementations of the present embodiment, picture processing model can be also used for processing standard size collection Other standard-sized pictures in conjunction in addition to target size, i.e., above-mentioned picture processing model can handle preset various marks The picture of object staff cun.
The method provided by the above embodiment of the application is by obtaining picture to be processed, from preset standard size set Standard size corresponding with picture to be processed is chosen as target size.Then, by the size adjusting of picture to be processed to selection Target size, and picture adjusted input picture trained in advance is handled into model, processing result is obtained, thus by pre- If multiple standards size can be according to specific picture to be processed, by figure to be processed when adjusting the size of picture to be processed The size adjusting of piece helps to improve flexibility when dimension of picture adjustment to corresponding standard size.
With further reference to Fig. 3, it illustrates the processes 300 of another embodiment of the method for handling picture.The use In the process 300 of processing picture, include the following steps:
Step 301, picture to be processed is obtained.
The specific implementation procedure of this step can refer to the related description of the step 201 in Fig. 2 corresponding embodiment, herein not It repeats again.
Step 302, the smallest standard of difference with the size of picture to be processed is chosen from preset standard size set Size is as target size.
In the present embodiment, each standard size in preset standard size set and picture to be processed can be determined respectively Size difference, then choose wherein the corresponding standard size of the smallest difference as target size.Wherein, picture to be processed Size can be determined according to actual application scenarios using a variety of different calculations with standard-sized difference.
It is alternatively possible to directly by the difference of the length of picture to be processed length corresponding with standard size or to be processed Size and standard-sized difference of the difference of the width of picture width corresponding with standard size as picture to be processed.
Optionally, the difference of the length length corresponding with standard size of picture to be processed, Ke Yiji can also first be calculated For the first difference;Then, the difference for calculating the width width corresponding with standard size of picture to be processed, it is poor can be denoted as second Value;It is then possible to calculate the quadratic sum of above-mentioned first difference and the second difference, and using calculated quadratic sum as figure to be processed The size of piece and standard-sized difference.
Optionally, when the size of picture is the resolution ratio of picture, Horizontal number of pixels and vertical picture is can be used in resolution ratio Prime number indicates.At this point it is possible to as follows come determine two pictures size difference.
The first step, can determine the size of picture to be processed, and calculate the Horizontal number of pixels of picture to be processed and vertical picture The ratio of prime number can be denoted as the first ratio.
Second step calculates Horizontal number of pixels corresponding to the standard size being compared with the size of picture to be processed and hangs down The ratio of straight pixel number, can be denoted as the second ratio.
Third step, the ruler of two pictures using above-mentioned first ratio with the absolute value of the difference of above-mentioned second ratio as compared with Very little difference.
Step 303, the picture to be processed by the size adjusting of picture to be processed to target size, after being adjusted.
Step 304, picture to be processed adjusted is input to picture trained in advance and handles model, obtain processing knot Fruit.
The specific implementation procedure of above-mentioned steps 303 and 304 can refer to step 203 in Fig. 2 corresponding embodiment and 204 Related description, details are not described herein.
It is that one of the application scenarios of the method according to the present embodiment for handling picture shows with further reference to Fig. 4, Fig. 4 It is intended to.In the application scenarios of Fig. 4, the resolution ratio of picture 401 to be processed is 320*480, wherein Horizontal number of pixels 320 hangs down Straight pixel number is 480.Preset standard size set 402 includes three standard sizes, respectively:240*320,960*640, 480*800.It is then possible to calculate separately the size and each standard-sized difference of picture to be processed.
Specifically, it for standard size 240*320, can first calculate the Horizontal number of pixels of picture to be processed and vertical picture The ratio of prime number is 320/480.Then, the ratio for calculating the standard-sized Horizontal number of pixels and Vertical number of pixels is 240/ 320.Later, size and standard size 240* of the absolute value as picture to be processed of the difference of above-mentioned two ratio can be calculated 320 difference is 1/12, as shown in figure label 403.Likewise it is possible to calculate the size and standard size of picture to be processed The difference of 960*640 is 5/6, as shown in figure label 404 and the size of picture to be processed and standard size 480*800 Difference is 1/15, as shown in figure label 405.
Later, it is 1/15 that the smallest difference can be selected from above-mentioned calculated three differences.Therefore, by the minimum The corresponding standard size 480*800 of difference as target size.It then, can be by the size adjusting of picture 401 to be processed extremely Above-mentioned target size 480*800, the picture to be processed 406 after being adjusted.
It is then possible to which picture 406 to be processed adjusted, which is inputted picture trained in advance, handles model 407, and then obtain To processing result 408.Alternatively, three picture processing models can also be trained in advance, correspond respectively in standard size set 402 Three kinds of sizes.At this point, picture to be processed adjusted to be input to the corresponding picture of size of picture to be processed adjusted Model is handled to obtain processing result.
From figure 3, it can be seen that compared with the corresponding embodiment of Fig. 2, the process of the information-pushing method in the present embodiment 300 can picture more to be processed size and each standard-sized difference in standard size set, and by figure to be processed The size adjusting of piece to the smallest difference corresponds to standard size, is then handled picture to be processed adjusted As a result.As a result, the present embodiment description scheme and the size in the prior art by different pictures to be processed uniformly adjust to A same standard size is compared, and this method helps to mitigate due to dimension of picture to be processed adjustment and bring distortion or change The degree of shape, and then also contribute to mitigating subsequent at it caused by distortion or deformation due to picture to be processed adjusted Manage the influence of result.
With further reference to Fig. 5, as the realization to method shown in above-mentioned each figure, this application provides for handling picture One embodiment of device, the Installation practice is corresponding with embodiment of the method shown in Fig. 2, which specifically can be applied to In various electronic equipments.
As shown in figure 5, it is provided in this embodiment for handle picture device 500 include obtain 501, selection unit 502, Adjustment unit 503 and processing unit 504.Wherein, acquiring unit 501 is configured to obtain picture to be processed.502 quilt of selection unit It is configured to choose standard size corresponding with picture to be processed from preset standard size set as target size.Adjustment is single Member 503 is configured to the size adjusting of picture to be processed to target size, the picture to be processed after being adjusted.Processing unit 504 are configured to for picture to be processed adjusted being input to picture processing model trained in advance, obtain processing result.
In the present embodiment, in the device 500 for handling picture:Acquiring unit 501, selection unit 502, adjustment unit 503 and processing unit 504 specific processing and its brought technical effect can be respectively with reference to the step in Fig. 2 corresponding embodiment 201, the related description of step 202, step 203 and step 204, details are not described herein.
In some optional implementations of the present embodiment, above-mentioned selection unit 502 is further configured to:Determine to Handle the size of picture;Based on the size of picture to be processed, chosen and picture pair to be processed from preset standard size set The standard size answered is as target size.
In some optional implementations of the present embodiment, above-mentioned selection unit 502 is further configured to:Choose with The smallest standard size of the difference of the size of picture to be processed is as target size.
In some optional implementations of the present embodiment, the size of picture to be processed is the resolution of picture to be processed The resolution ratio of rate, picture to be processed is indicated with Horizontal number of pixels and Vertical number of pixels;And for the mark in standard size set Object staff cun, the difference of the standard size and the size of picture to be processed determines as follows:Determine the water of picture to be processed The ratio of flat pixel number and Vertical number of pixels;Determine the ratio of the standard size corresponding Horizontal number of pixels and Vertical number of pixels; By the ratio of the Horizontal number of pixels of picture to be processed and Vertical number of pixels Horizontal number of pixels corresponding with the standard size and vertical Difference of the absolute value of the difference of the ratio of pixel number as the standard size and the size of picture to be processed.
In some optional implementations of the present embodiment, above-mentioned selection unit 502 is further configured to:Determine to Handle the content information of picture;According to the content information and standard-sized corresponding relationship pre-established, determining and figure to be processed The corresponding standard size of the highest content information of the similarity of the content information of piece is as target size.
In some optional implementations of the present embodiment, training obtains picture processing model as follows:It obtains Take training sample set, wherein training sample includes the processing result of samples pictures and samples pictures;For training sample set In training sample, from choosing corresponding with the samples pictures in training sample standard size in standard size set, and Samples pictures by the size adjusting of the samples pictures in the training sample to selected standard size, after being adjusted;Benefit With the method for machine learning, by the corresponding samples pictures adjusted of the samples pictures in the training sample in training sample set As input, using processing result corresponding with the samples pictures adjusted of input as desired output, training is obtained at picture Manage model.
The device provided by the above embodiment of the application obtains picture to be processed by acquiring unit, and selection unit is from pre- If standard size set in choose corresponding with picture to be processed standard size as target size, adjustment unit will be to be processed The size adjusting of picture is to target size, picture to be processed after being adjusted, then by processing unit by it is adjusted to Reason picture is input to picture processing model trained in advance, obtains processing result, thus by preset multiple standards size, When adjusting the size of picture to be processed, can according to specific picture to be processed, by the size adjusting of picture to be processed to and its Corresponding standard size helps to improve flexibility when dimension of picture adjustment.
Below with reference to Fig. 6, it illustrates the computer systems 600 for the electronic equipment for being suitable for being used to realize the embodiment of the present application Structural schematic diagram.Electronic equipment shown in Fig. 6 is only an example, function to the embodiment of the present application and should not use model Shroud carrys out any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and Execute various movements appropriate and processing.In RAM 603, also it is stored with system 600 and operates required various programs and data. CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 is also connected to always Line 604.
I/O interface 605 is connected to lower component:Importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.; And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon Computer program be mounted into storage section 608 as needed.
Particularly, in accordance with an embodiment of the present disclosure, it may be implemented as computer above with reference to the process of flow chart description Software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable medium On computer program, which includes the program code for method shown in execution flow chart.In such reality It applies in example, which can be downloaded and installed from network by communications portion 609, and/or from detachable media 611 are mounted.When the computer program is executed by central processing unit (CPU) 601, limited in execution the present processes Above-mentioned function.
It should be noted that the computer-readable medium of the application can be computer-readable signal media or computer Readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but it is unlimited In system, device or the device of --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, or any above combination.It calculates The more specific example of machine readable storage medium storing program for executing can include but is not limited to:It is electrical connection with one or more conducting wires, portable Formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device or The above-mentioned any appropriate combination of person.In this application, computer readable storage medium can be it is any include or storage program Tangible medium, which can be commanded execution system, device or device use or in connection.And in this Shen Please in, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, In carry computer-readable program code.The data-signal of this propagation can take various forms, including but not limited to Electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be computer-readable Any computer-readable medium other than storage medium, the computer-readable medium can send, propagate or transmit for by Instruction execution system, device or device use or program in connection.The journey for including on computer-readable medium Sequence code can transmit with any suitable medium, including but not limited to:Wirelessly, electric wire, optical cable, RF etc. or above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of the module, program segment or code include one or more use The executable instruction of the logic function as defined in realizing.It should also be noted that in some implementations as replacements, being marked in box The function of note can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are actually It can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it to infuse Meaning, the combination of each box in block diagram and or flow chart and the box in block diagram and or flow chart can be with holding The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in unit involved in the embodiment of the present application can be realized by way of software, can also be by hard The mode of part is realized.Described unit also can be set in the processor, for example, can be described as:A kind of processor, packet Include acquiring unit, selection unit, adjustment unit and processing unit.Wherein, the title of these units not structure under certain conditions The restriction of the pairs of unit itself, for example, acquiring unit is also described as " obtaining the unit of picture to be processed ".
As on the other hand, present invention also provides a kind of computer-readable medium, which be can be Included in device described in above-described embodiment;It is also possible to individualism, and without in the supplying device.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the device, so that should Device:Obtain picture to be processed;Standard size conduct corresponding with picture to be processed is chosen from preset standard size set Target size;Picture to be processed by the size adjusting of picture to be processed to target size, after being adjusted;By it is adjusted to Processing picture is input to picture processing model trained in advance, obtains processing result.
Above description is only the preferred embodiment of the application and the explanation to institute's application technology principle.Those skilled in the art Member is it should be appreciated that invention scope involved in the application, however it is not limited to technology made of the specific combination of above-mentioned technical characteristic Scheme, while should also cover in the case where not departing from foregoing invention design, it is carried out by above-mentioned technical characteristic or its equivalent feature Any combination and the other technical solutions formed.Such as features described above has similar function with (but being not limited to) disclosed herein Can technical characteristic replaced mutually and the technical solution that is formed.

Claims (14)

1. a kind of method for handling picture, including:
Obtain picture to be processed;
Standard size corresponding with the picture to be processed is chosen from preset standard size set as target size;
Picture to be processed by the size adjusting of the picture to be processed to the target size, after being adjusted;
The picture to be processed adjusted is input to picture trained in advance and handles model, obtains processing result.
2. according to the method described in claim 1, wherein, it is described chosen from preset standard size set with it is described to be processed The corresponding standard size of picture as target size, including:
Determine the size of the picture to be processed;
Based on the size of the picture to be processed, chosen from preset standard size set corresponding with the picture to be processed Standard size is as target size.
3. according to the method described in claim 2, wherein, the size based on the picture to be processed, from preset standard Standard size corresponding with the picture to be processed is chosen in size set as target size, including:
The smallest standard size of difference with the size of the picture to be processed is chosen as target size.
4. according to the method described in claim 3, wherein, the size of the picture to be processed is the resolution of the picture to be processed The resolution ratio of rate, the picture to be processed is indicated with Horizontal number of pixels and Vertical number of pixels;And
For the standard size in the standard size set, the difference of the size of the standard size and the picture to be processed is logical Following steps are crossed to determine:
Determine the Horizontal number of pixels of the picture to be processed and the ratio of Vertical number of pixels;
Determine the ratio of the standard size corresponding Horizontal number of pixels and Vertical number of pixels;
By the ratio of the Horizontal number of pixels of the picture to be processed and Vertical number of pixels horizontal pixel corresponding with the standard size Difference of the absolute value of the difference of several and Vertical number of pixels ratio as the standard size and the size of the picture to be processed.
5. according to the method described in claim 1, wherein, it is described chosen from preset standard size set with it is described to be processed The corresponding standard size of picture as target size, including:
Determine the content information of the picture to be processed;
According to the content information and standard-sized corresponding relationship pre-established, the determining content information with the picture to be processed The corresponding standard size of the highest content information of similarity as target size.
6. method described in one of -5 according to claim 1, wherein picture processing model is trained as follows It arrives:
Obtain training sample set, wherein training sample includes the processing result of samples pictures and samples pictures;
For the training sample in the training sample set, from chosen in the standard size set in the training sample The corresponding standard size of samples pictures, and by the size adjusting of the samples pictures in the training sample to selected gauge It is very little, the samples pictures after being adjusted;
Using the method for machine learning, after the corresponding adjustment of samples pictures in the training sample in the training sample set Samples pictures as input, processing result corresponding with the samples pictures adjusted of input is used as to desired output, it is trained Obtain the picture processing model.
7. it is a kind of for handling the device of picture, including:
Acquiring unit is configured to obtain picture to be processed;
Selection unit is configured to choose standard size corresponding with the picture to be processed from preset standard size set As target size;
Adjustment unit is configured to the size adjusting of the picture to be processed to the target size, after being adjusted to Handle picture;
Processing unit is configured to for the picture to be processed adjusted being input to picture processing model trained in advance, obtains To processing result.
8. device according to claim 7, wherein the selection unit is further configured to:
Determine the size of the picture to be processed;
Based on the size of the picture to be processed, chosen from preset standard size set corresponding with the picture to be processed Standard size is as target size.
9. device according to claim 8, wherein the selection unit is further configured to:It chooses with described wait locate The smallest standard size of difference of the size of picture is managed as target size.
10. device according to claim 9, wherein the size of the picture to be processed is point of the picture to be processed The resolution ratio of resolution, the picture to be processed is indicated with Horizontal number of pixels and Vertical number of pixels;And
For the standard size in the standard size set, the difference of the size of the standard size and the picture to be processed is logical Following steps are crossed to determine:
Determine the Horizontal number of pixels of the picture to be processed and the ratio of Vertical number of pixels;
Determine the ratio of the standard size corresponding Horizontal number of pixels and Vertical number of pixels;
By the ratio of the Horizontal number of pixels of the picture to be processed and Vertical number of pixels horizontal pixel corresponding with the standard size Difference of the absolute value of the difference of several and Vertical number of pixels ratio as the standard size and the size of the picture to be processed.
11. device according to claim 7, wherein the selection unit is further configured to:
Determine the content information of the picture to be processed;
According to the content information and standard-sized corresponding relationship pre-established, the determining content information with the picture to be processed The corresponding standard size of the highest content information of similarity as target size.
12. the device according to one of claim 7-11, wherein picture processing model is trained as follows It arrives:
Obtain training sample set, wherein training sample includes the processing result of samples pictures and samples pictures;
For the training sample in the training sample set, from chosen in the standard size set in the training sample The corresponding standard size of samples pictures, and by the size adjusting of the samples pictures in the training sample to selected gauge It is very little, the samples pictures after being adjusted;
Using the method for machine learning, after the corresponding adjustment of samples pictures in the training sample in the training sample set Samples pictures as input, processing result corresponding with the samples pictures adjusted of input is used as to desired output, it is trained Obtain the picture processing model.
13. a kind of electronic equipment, including:
One or more processors;
Storage device is stored thereon with one or more programs;
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as method as claimed in any one of claims 1 to 6.
14. a kind of computer-readable medium, is stored thereon with computer program, wherein the realization when program is executed by processor Such as method as claimed in any one of claims 1 to 6.
CN201810714637.5A 2018-07-03 2018-07-03 Method and device for processing pictures Active CN108921792B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810714637.5A CN108921792B (en) 2018-07-03 2018-07-03 Method and device for processing pictures
PCT/CN2018/116336 WO2020006962A1 (en) 2018-07-03 2018-11-20 Method and device for processing picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810714637.5A CN108921792B (en) 2018-07-03 2018-07-03 Method and device for processing pictures

Publications (2)

Publication Number Publication Date
CN108921792A true CN108921792A (en) 2018-11-30
CN108921792B CN108921792B (en) 2023-06-27

Family

ID=64425242

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810714637.5A Active CN108921792B (en) 2018-07-03 2018-07-03 Method and device for processing pictures

Country Status (2)

Country Link
CN (1) CN108921792B (en)
WO (1) WO2020006962A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113449139A (en) * 2020-03-24 2021-09-28 阿里巴巴集团控股有限公司 Method, device and system for generating matching graph
CN113409204A (en) * 2021-06-10 2021-09-17 Oppo广东移动通信有限公司 Method and device for optimizing image to be processed, storage medium and electronic equipment
CN113821278B (en) * 2021-09-06 2024-05-03 挂号网(杭州)科技有限公司 Calling image size method, device, electronic equipment and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105095911A (en) * 2015-07-31 2015-11-25 小米科技有限责任公司 Sensitive picture identification method and apparatus, and server
CN105139033A (en) * 2015-08-24 2015-12-09 小米科技有限责任公司 Classifier construction method and device and image processing method and device
WO2015197009A1 (en) * 2014-06-27 2015-12-30 Tencent Technology (Shenzhen) Company Limited Picture processing method and apparatus
CN106096605A (en) * 2016-06-02 2016-11-09 史方 A kind of image obscuring area detection method based on degree of depth study and device
CN106250921A (en) * 2016-07-26 2016-12-21 北京小米移动软件有限公司 Image processing method and device
WO2017113533A1 (en) * 2015-12-30 2017-07-06 完美幻境(北京)科技有限公司 Panoramic photographing method and device
CN107220652A (en) * 2017-05-31 2017-09-29 北京京东尚科信息技术有限公司 Method and apparatus for handling picture
CN107578375A (en) * 2017-08-21 2018-01-12 北京陌上花科技有限公司 Image processing method and device
CN108133201A (en) * 2018-01-17 2018-06-08 百度在线网络技术(北京)有限公司 Face character recognition methods and device
CN108154547A (en) * 2018-01-17 2018-06-12 百度在线网络技术(北京)有限公司 Image generating method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015197009A1 (en) * 2014-06-27 2015-12-30 Tencent Technology (Shenzhen) Company Limited Picture processing method and apparatus
CN105095911A (en) * 2015-07-31 2015-11-25 小米科技有限责任公司 Sensitive picture identification method and apparatus, and server
CN105139033A (en) * 2015-08-24 2015-12-09 小米科技有限责任公司 Classifier construction method and device and image processing method and device
WO2017113533A1 (en) * 2015-12-30 2017-07-06 完美幻境(北京)科技有限公司 Panoramic photographing method and device
CN106096605A (en) * 2016-06-02 2016-11-09 史方 A kind of image obscuring area detection method based on degree of depth study and device
CN106250921A (en) * 2016-07-26 2016-12-21 北京小米移动软件有限公司 Image processing method and device
CN107220652A (en) * 2017-05-31 2017-09-29 北京京东尚科信息技术有限公司 Method and apparatus for handling picture
CN107578375A (en) * 2017-08-21 2018-01-12 北京陌上花科技有限公司 Image processing method and device
CN108133201A (en) * 2018-01-17 2018-06-08 百度在线网络技术(北京)有限公司 Face character recognition methods and device
CN108154547A (en) * 2018-01-17 2018-06-12 百度在线网络技术(北京)有限公司 Image generating method and device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
徐有正;黄刚;: "多标签图像的识别分类处理算法", 计算机时代, no. 10 *
曲长文;刘晨;周强;李智;李健伟;: "基于分块CNN的多尺度SAR图像目标分类算法", 雷达科学与技术, no. 02 *
曾超;陈雨;: "车牌超分辨率重建与识别", 计算机测量与控制, no. 03 *

Also Published As

Publication number Publication date
CN108921792B (en) 2023-06-27
WO2020006962A1 (en) 2020-01-09

Similar Documents

Publication Publication Date Title
CN107633218B (en) Method and apparatus for generating image
CN107578017B (en) Method and apparatus for generating image
CN108898185A (en) Method and apparatus for generating image recognition model
CN108986169A (en) Method and apparatus for handling image
CN108898186A (en) Method and apparatus for extracting image
CN108595628A (en) Method and apparatus for pushed information
CN109255337A (en) Face critical point detection method and apparatus
CN107919129A (en) Method and apparatus for controlling the page
CN109255767A (en) Image processing method and device
CN109410253B (en) For generating method, apparatus, electronic equipment and the computer-readable medium of information
CN109389640A (en) Image processing method and device
CN108984399A (en) Detect method, electronic equipment and the computer-readable medium of interface difference
CN109344762A (en) Image processing method and device
CN109118456A (en) Image processing method and device
CN109344752A (en) Method and apparatus for handling mouth image
CN108876858A (en) Method and apparatus for handling image
CN108882025A (en) Video frame treating method and apparatus
CN108960110A (en) Method and apparatus for generating information
CN109241934A (en) Method and apparatus for generating information
CN109377508A (en) Image processing method and device
CN109285181A (en) The method and apparatus of image for identification
CN109117758A (en) Method and apparatus for generating information
CN109272050B (en) Image processing method and device
CN109711508A (en) Image processing method and device
CN109389096A (en) Detection method and device

Legal Events

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