Invention content
To solve the above-mentioned problems, the embodiment of the invention discloses a kind of picture method of cutting out and device, particular technique sides
Case is as follows:
A kind of picture method of cutting out provided by the invention, this method are used to cut the picture that angle rotation occurs,
Including:
It receives picture input by user and cuts instruction;Wherein, the picture cuts the position that crop box is carried in instruction
Information;
According to the location information of crop box, judge whether the overlay area of the crop box is fully located at picture to be cut
In picture region, if so, being cut using the crop box to the picture to be cut;
Otherwise, the overlay area of the crop box is adjusted to the picture region to be cut, after adjustment
Crop box cuts the picture to be cut.
According in a kind of specific embodiment provided by the invention, the location information according to crop box, described in judgement
Whether the overlay area of crop box is fully located in the picture region of picture to be cut, including:
Two-dimensional Cartesian coordinate system is established using a point in the picture region of the picture to be cut as origin, described in calculating
The linear equation of the four edges of picture to be cut;
According to the location information of crop box, four endpoints of the crop box under same two-dimensional Cartesian coordinate system are determined
Coordinate value;
According to the linear equation and coordinate value, judge whether four endpoints of the crop box are located at the linear equation
In the region of composition, if it is, the overlay area of the crop box is fully located in the picture region of picture to be cut, otherwise
Not exclusively it is located at.
According in a kind of specific embodiment provided by the invention, a point in the picture region of the picture to be cut
Endpoint for the picture to be cut.
According in a kind of specific embodiment provided by the invention, the four edges of picture to be cut described in the calculating it is straight
Line equation, including:
According to the rotation angle of the picture length of the picture to be cut, width and picture, picture to be cut described in calculating
Four edges linear equation;
Or
According to four extreme coordinates values of the picture to be cut, the straight line side of the four edges of picture to be cut described in calculating
Journey.
It is described according to the linear equation and coordinate value according in a kind of specific embodiment provided by the invention, judge
Whether four endpoints of the crop box are located in the region that the linear equation is formed, including:
According to the linear equation, generation corresponds to four functions of the four edges of the picture to be cut;
Four endpoints of the crop box are substituted into four letters corresponding to the four edges of the picture to be cut respectively
In number;
For each function, judge the crop box four endpoints substitute into the function result whether jack per line;
If equal jack per line, further directed to two functions corresponding to every group each other side of opposite side, the crop box is judged
Four endpoints substitute into two functions result whether contrary sign, if equal contrary sign, four endpoints of the crop box are located at
In the region that the linear equation is formed.
According in a kind of specific embodiment provided by the invention, adjusted in the overlay area by the crop box to
Before in the picture region to be cut, further include:
It shows to user and is prompted for the first message of picture region that crop box is prompted to exceed picture to be cut.
According in a kind of specific embodiment provided by the invention, adjusted in the overlay area by the crop box to
Before in the picture region to be cut, further include:
It shows to user and disappears for asking whether to receive that overlay area is adjusted second to picture region by system automatically
Breath prompting;
After the affirmative operation that user makes for second message prompting is received, perform described by the crop box
Overlay area adjust to the step in the picture region to be cut.
A kind of picture Scissoring device provided by the invention, the device are used to cut the picture that angle rotation occurs,
Including:
Command reception module cuts instruction for receiving picture input by user;Wherein, the picture cuts in instruction and takes
Location information with crop box;
Judgment module according to the location information of crop box, judges whether the overlay area of the crop box is fully located at and treats
In the picture region for cutting picture;
First cuts module, in the case where the judging result of the judgment module is to be, using the crop box
The picture to be cut is cut;
Second cuts module, in the case of being no in the judging result of the judgment module, by the crop box
Overlay area is adjusted to the picture region to be cut, and the picture to be cut is carried out using the crop box after adjustment
It cuts.
According in a kind of specific embodiment provided by the invention, the judgment module, including:
Linear equation computational submodule, for being established by origin of a point in the picture region of the picture to be cut
Two-dimensional Cartesian coordinate system, the linear equation of the four edges of picture to be cut described in calculating;
Coordinate value determination sub-module for the location information according to crop box, is determined under same two-dimensional Cartesian coordinate system
The coordinate value of four endpoints of the crop box;
Judging submodule, for whether according to the linear equation and coordinate value, judging four endpoints of the crop box
In the region that the linear equation is formed, if it is, the overlay area of the crop box is fully located at picture to be cut
Picture region in, be otherwise not exclusively located at.
According in a kind of specific embodiment provided by the invention, a point in the picture region of the picture to be cut
Endpoint for the picture to be cut.
According in a kind of specific embodiment provided by the invention, the linear equation computational submodule is specifically used for:
Two-dimensional Cartesian coordinate system is established as origin using a point in the picture region of the picture to be cut, according to described
The rotation angle of the picture length of picture to be cut, width and picture, the straight line side of the four edges of picture to be cut described in calculating
Journey;
Or
Two-dimensional Cartesian coordinate system is established as origin using a point in the picture region of the picture to be cut, according to described
Four extreme coordinates values of picture to be cut, the linear equation of the four edges of picture to be cut described in calculating.
According in a kind of specific embodiment provided by the invention, the judging submodule is specifically used for:
According to the linear equation, generation corresponds to four functions of the four edges of the picture to be cut;
Four endpoints of the crop box are substituted into four letters corresponding to the four edges of the picture to be cut respectively
In number;
For each function, judge the crop box four endpoints substitute into the function result whether jack per line;
If equal jack per line, further directed to two functions corresponding to every group each other side of opposite side, the crop box is judged
Four endpoints substitute into two functions result whether contrary sign, if equal contrary sign, four endpoints of the crop box are located at
In the region that the linear equation is formed.
According in a kind of specific embodiment provided by the invention, described device further includes:
First message prompts display module, for showing that crop box is prompted to exceed the figure of picture to be cut to user
The first message prompting of panel region.
According in a kind of specific embodiment provided by the invention, described device further includes:
Second message prompts display module, for showing to ask whether to receive system automatically by overlay area to user
Adjust the second message prompting to picture region;
Execution module is triggered, for after the affirmative operation that user makes for second message prompting is received, touching
Send out described second cutting module execution the overlay area of the crop box is adjusted to the behaviour in the picture region to be cut
Make.
Using above-mentioned technical proposal, picture method of cutting out and device provided in an embodiment of the present invention can receive use
After the picture of family input cuts instruction, the location information of crop box that carries in instruction is cut according to the picture, described in judgement
Whether the overlay area of crop box is fully located in the picture region of picture to be cut, if so, using the crop box to institute
Picture to be cut is stated to be cut;Otherwise, the overlay area of the crop box is adjusted to the picture region to be cut
It is interior, the picture to be cut is cut using the crop box after adjustment.
Compared with prior art, the present invention can be directed to the picture that angle rotation occurs, by comparing the covering of crop box
Whether region falls into the mode in the picture region of picture to be cut, and determines specifically using which kind of cutting method, so as to ensure
When user cuts the picture that angle rotation occurs, crop box is without departing from the picture region of picture to be cut.
Specific embodiment
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below in conjunction with of the invention real
The attached drawing in example is applied, the technical solution in the embodiment of the present invention is clearly and completely described, it is clear that described implementation
Example is only part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, this field is common
Technical staff's all other embodiments obtained without making creative work belong to the model that the present invention protects
It encloses.
With the type for the image processing software that the fast development of image processing techniques, image processing software developer provide
More and more, function is increasingly abundanter.The image processing software of mainstream is respectively provided with image cropping function at present.Image processing software
When being cut to picture, realized by crop box, user can come by adjusting modes such as crop box size, positions
Obtain the image-region for it is expected content.
However, due to use crop box to occur angle rotation picture carry out cut make when, it is difficult to ensure that crop box
The picture region of picture to be cut is fallen completely within, therefore there is an urgent need for propose a kind of picture method of cutting out to solve the above problems.In order to
It solves the above problems, an embodiment of the present invention provides a kind of picture method of cutting out and devices.
A kind of picture method of cutting out provided in an embodiment of the present invention is introduced first below.
It should be noted that method provided in an embodiment of the present invention is suitable for electronic equipment, in practical applications, the electronics
Equipment can include:The electronic equipments such as smart mobile phone, tablet computer, notebook/desktop computer.
As shown in Figure 1, a kind of picture method of cutting out provided in an embodiment of the present invention, this method is used for angle rotation occurs
Picture cut, can include:
S101 receives picture input by user and cuts instruction;Wherein, the picture cuts in instruction and carries crop box
Location information.
The present invention can provide the interface that input picture cuts instruction, in practical applications, the form of the interface to the user
It can include:The size value input interface of crop box can receive touch screen or operate size of the equipment such as mouse to crop box
Or position is adjusted interface.It is not limited in the embodiment of the present invention.
S102 according to the location information of crop box, judges whether the overlay area of the crop box is fully located at and waits to cut
In the picture region of picture.
Optionally, as shown in Fig. 1 (a), above-mentioned S102 can include:
S102a establishes two-dimensional Cartesian coordinate system using a point in the picture region of the picture to be cut as origin, meter
The linear equation of the four edges of picture to be cut described in calculation.
Preferably, a point in the picture region of the picture to be cut is that the endpoint of the picture to be cut for example is treated
Cut the upper left endpoint of picture.
Specifically, in the specific embodiment of the present invention, the four edges of picture to be cut described in the calculating
Linear equation can include:
According to the rotation angle of the picture length of the picture to be cut, width and picture, picture to be cut described in calculating
Four edges linear equation.
Such as Fig. 1 (b) show the picture to be cut when angle rotation not occurring, Fig. 1 (c), which is shown, occurs angle rotation
When picture to be cut, wherein A, B, C, D be picture four endpoints, coordinate system, X are established as origin using the A points in Fig. 1 (b)
It is axial right just, under Y-axis to be just, to establish coordinate system, for the picture that angle rotation occurs, following information can be obtained:
1. width W, the height V of the picture of angle rotation occurs;
2. the rotation angle of picture is represented with letter α;
First, the AB, BC, CD of the picture before being rotated according to condition 1 in the hope of angle, the linear equation point of DA four edges
It Wei not x=0, y=0, x=W, y=V;
Later, according to picture rotation angle [alpha] can in the hope of the AB of the postrotational picture of angle, BC, CD, DA four edges it is straight
Line equation.
It is appreciated that the coordinate of two points known in two-dimensional Cartesian coordinate system, it can be aforementioned 2 points in the hope of a process
Linear equation, in the another embodiment of the present invention, the four edges of picture to be cut described in the calculating it is straight
Line equation can include:
According to four extreme coordinates values of the picture to be cut, the straight line side of the four edges of picture to be cut described in calculating
Journey.
S102b according to the location information of crop box, determines four of the crop box under same two-dimensional Cartesian coordinate system
The coordinate value of endpoint.
Four endpoints and coordinate value of crop box as shown in Fig. 1 (c):A1 points (ax1, ay1), B1 points (bx1, by1), C1
Point (cx1, cy1) and D1 points (dx1, dy1).
Whether S102c according to the linear equation and coordinate value, judges four endpoints of the crop box positioned at described straight
In the region that line equation is formed, if it is, the overlay area of the crop box is fully located at the picture region of picture to be cut
It is interior, otherwise not exclusively it is located at.
Specifically, above-mentioned S102c, can include:
According to the linear equation, generation corresponds to four functions of the four edges of the picture to be cut;
Illustratively, it is assumed that the corresponding linear equations of AB are:Ex+Fy+G=0 (E, F, G are a certain constant), then AB is corresponded to
Function for f (x, y)=Ex+Fy+G, similarly can be in the hope of other corresponding functions in three sides.
Four endpoints of the crop box are substituted into four letters corresponding to the four edges of the picture to be cut respectively
In number;
For each function, judge the crop box four endpoints substitute into the function result whether jack per line;
If equal jack per line, further directed to two functions corresponding to every group each other side of opposite side, the crop box is judged
Four endpoints substitute into two functions result whether contrary sign, if equal contrary sign, four endpoints of the crop box are located at
In the region that the linear equation is formed.
Example illustratively is connected, the coordinate value A1 points (ax1, ay1) of above-mentioned four endpoints of crop box, B1 points (bx1,
By1), C1 points (cx1, cy1) and D1 points (dx1, dy1) are brought into the corresponding functions of AB, are obtained:
E*ax1+F*ay1+G<=0 and E*bx1+F*by1+G<=0 and E*cx1+F*cy1+G<=0 and E*dx1+
F*dy1+G<=0 sets up --- --- condition 1 simultaneously
E*ax1+F*ay1+G>=0 and E*bx1+F*by1+G>=0 and E*cx1+F*cy1+G>=0 and E*dx1+
F*dy1+G>=0 sets up --- --- condition 2 simultaneously
Pay attention to:Condition 1 set up represent four terminal As 1 of crop box, B1, C1 and D1 straight line AB homonymy, condition 2 into
Vertical four terminal As 1 for representing crop box, B1, C1 and D1 straight line AB homonymy.
Assuming that the corresponding linear equations of CD are:Hx+Jy+K=0 (H, J, K are a certain constant), then the corresponding functions of CD are f
(x, y)=Hx+Jy+K;The coordinate value A1 points (ax1, ay1) of above-mentioned four endpoints of crop box, B1 points (bx1, by1), C1 points
(cx1, cy1) and D1 points (dx1, dy1) are brought into the corresponding functions of CD, are obtained:
H*ax1+J*ay1+K>=0 and H*bx1+J*by1+K>=0 and H*cx1+J*cy1+K>=0 and H*dx1+
J*dy1+K>=0 sets up --- --- condition 3 simultaneously
H*ax1+J*ay1+K<=0 and H*bx1+J*by1+K<=0 and H*cx1+J*cy1+K<=0 and H*dx1+
J*dy1+K<=0 sets up --- --- condition 4 simultaneously
Pay attention to:Condition 3 set up represent four terminal As 1 of crop box, B1, C1 and D1 straight line CD homonymy, condition 4 into
Vertical four terminal As 1 for representing crop box, B1, C1 and D1 straight line CD homonymy.
Ensuring the condition that four terminal As 1 of crop box, B1, C1 and D1 are located at the edge detection in picture region is:Condition
1 and condition 3 need to set up simultaneously or condition 2 and condition 4 at the same set up (ensure here be cut out frame AB and CD it
Between).The edge testing conditions that this group of opposite side needs of BC and DA meet can similarly be obtained.
S103 cuts the picture to be cut using the crop box.
S104 adjusts the overlay area of the crop box to the picture region to be cut, after adjustment
Crop box cuts the picture to be cut.
The adjustment of the overlay area to crop box in step of the present invention, can include:To the overlay area of crop box
The adjustment of position or the adjustment of size to the overlay area of crop box.
It can be seen that picture method of cutting out provided in an embodiment of the present invention, can cut out receiving picture input by user
After cutting instruction, the location information of crop box carried in instruction is cut according to the picture, judges the area of coverage of the crop box
Whether domain is fully located in the picture region of picture to be cut, if so, using the crop box to the picture to be cut
It is cut;Otherwise, the overlay area of the crop box is adjusted to the picture region to be cut, after adjustment
Crop box cuts the picture to be cut.
Compared with prior art, the present invention can be directed to the picture that angle rotation occurs, by comparing the covering of crop box
Whether region falls into the mode in the picture region of picture to be cut, and determines specifically using which kind of cutting method, so as to ensure
When user cuts the picture that angle rotation occurs, crop box is without departing from the picture region of picture to be cut.
Optionally, in another embodiment of the present invention, picture method of cutting out provided in an embodiment of the present invention, is judging
Go out the crop box overlay area not exclusively positioned at picture to be cut picture region in the case of, can also general described in
The overlay area of crop box is adjusted before to the picture region to be cut, and is included the following steps:
It shows to user and is prompted for the first message of picture region that crop box is prompted to exceed picture to be cut.
Optionally, in another embodiment of the present invention, picture method of cutting out provided in an embodiment of the present invention, is judging
Go out the crop box overlay area not exclusively positioned at picture to be cut picture region in the case of, can also general described in
The overlay area of crop box is adjusted before to the picture region to be cut, and is included the following steps:
It shows to user and disappears for asking whether to receive that overlay area is adjusted second to picture region by system automatically
Breath prompting;
After the affirmative operation that user makes for second message prompting is received, perform described by the crop box
Overlay area adjust to the step in the picture region to be cut.
The present embodiment step can be adjusted the overlay area of crop box after obtaining user and agreeing to, so as to cut
Image out is full of crop box and with rotation angle.
Corresponding to approach presented above embodiment, the embodiment of the present invention additionally provides a kind of picture Scissoring device.
As shown in Fig. 2, a kind of picture Scissoring device provided in an embodiment of the present invention, which is used for angle rotation occurs
Picture cut, can include:
Command reception module 201 cuts instruction for receiving picture input by user;Wherein, the picture cuts instruction
In carry the location information of crop box;
Judgment module 202 according to the location information of crop box, judges whether the overlay area of the crop box is fully located at
In the picture region of picture to be cut;
First cuts module 203, in the judging result of the judgment module 202 in the case of being, using described
Crop box cuts the picture to be cut;
Second cuts module 204, in the case of being no in the judging result of the judgment module 202, by the sanction
The overlay area for cutting frame is adjusted to the picture region to be cut, using the crop box after adjustment to the figure to be cut
Piece is cut.
It can be seen that picture Scissoring device provided in an embodiment of the present invention, can cut out receiving picture input by user
After cutting instruction, the location information of crop box carried in instruction is cut according to the picture, judges the area of coverage of the crop box
Whether domain is fully located in the picture region of picture to be cut, if so, using the crop box to the picture to be cut
It is cut;Otherwise, the overlay area of the crop box is adjusted to the picture region to be cut, after adjustment
Crop box cuts the picture to be cut.
Compared with prior art, the present invention can be directed to the picture that angle rotation occurs, by comparing the covering of crop box
Whether region falls into the mode in the picture region of picture to be cut, and determines specifically using which kind of cutting method, so as to ensure
When user cuts the picture that angle rotation occurs, crop box is without departing from the picture region of picture to be cut.
Optionally, in one embodiment of the invention, the judgment module 202, can include:
Linear equation computational submodule, for being established by origin of a point in the picture region of the picture to be cut
Two-dimensional Cartesian coordinate system, the linear equation of the four edges of picture to be cut described in calculating;
Coordinate value determination sub-module for the location information according to crop box, is determined under same two-dimensional Cartesian coordinate system
The coordinate value of four endpoints of the crop box;
Judging submodule, for whether according to the linear equation and coordinate value, judging four endpoints of the crop box
In the region that the linear equation is formed, if it is, the overlay area of the crop box is fully located at picture to be cut
Picture region in, be otherwise not exclusively located at.
Optionally, in one embodiment of the invention, a point in the picture region of the picture to be cut can be with
Endpoint for the picture to be cut.
Optionally, in one embodiment of the invention, the linear equation computational submodule, specifically can be used for:
Two-dimensional Cartesian coordinate system is established as origin using a point in the picture region of the picture to be cut, according to described
The rotation angle of the picture length of picture to be cut, width and picture, the straight line side of the four edges of picture to be cut described in calculating
Journey;
Or
Two-dimensional Cartesian coordinate system is established as origin using a point in the picture region of the picture to be cut, according to described
Four extreme coordinates values of picture to be cut, the linear equation of the four edges of picture to be cut described in calculating.
Optionally, in one embodiment of the invention, the judging submodule 202, specifically can be used for:
According to the linear equation, generation corresponds to four functions of the four edges of the picture to be cut;
Four endpoints of the crop box are substituted into four letters corresponding to the four edges of the picture to be cut respectively
In number;
For each function, judge the crop box four endpoints substitute into the function result whether jack per line;
If equal jack per line, further directed to two functions corresponding to every group each other side of opposite side, the crop box is judged
Four endpoints substitute into two functions result whether contrary sign, if equal contrary sign, four endpoints of the crop box are located at
In the region that the linear equation is formed.
Optionally, in one embodiment of the invention, described device can also include:
First message prompts display module, for showing that crop box is prompted to exceed the figure of picture to be cut to user
The first message prompting of panel region.
Optionally, in one embodiment of the invention, described device can also include:
Second message prompts display module, for showing to ask whether to receive system automatically by overlay area to user
Adjust the second message prompting to picture region;
Execution module is triggered, for after the affirmative operation that user makes for second message prompting is received, touching
Send out described second cutting module execution the overlay area of the crop box is adjusted to the behaviour in the picture region to be cut
Make.
For device embodiment, since it is substantially similar to embodiment of the method, so description is fairly simple, it is related
Part illustrates referring to the part of embodiment of the method.
For convenience of description, it is divided into various modules during description apparatus above with function to describe respectively.Certainly, implementing this
The function of each module is realized can in the same or multiple software and or hardware during invention.
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any this practical relationship or sequence.Moreover, term " comprising ", "comprising" or its any other variant are intended to
Non-exclusive inclusion, so that process, method, article or equipment including a series of elements not only will including those
Element, but also including other elements that are not explicitly listed or further include as this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
Also there are other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is described using relevant mode, identical similar portion between each embodiment
Point just to refer each other, and the highlights of each of the examples are difference from other examples.Especially for device reality
For applying example, since it is substantially similar to embodiment of the method, so description is fairly simple, related part is referring to embodiment of the method
Part explanation.
One of ordinary skill in the art will appreciate that all or part of step in realization above method embodiment is can
It is completed with instructing relevant hardware by program, the program can be stored in computer read/write memory medium,
The storage medium designated herein obtained, such as:ROM/RAM, magnetic disc, CD etc..
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all
Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention
It is interior.