Image processing apparatus and non-transitory computer readable medium for calculating a position at which to superimpose a design object onto an image
11475614 · 2022-10-18
Assignee
Inventors
Cpc classification
G06V10/26
PHYSICS
G06V10/462
PHYSICS
International classification
Abstract
An image processing apparatus includes a processor configured to receive an image having a foreground segment and a background segment, receive a design object, calculate a position for superimposing the design object, on a basis of respective features of the foreground segment, the background segment, and the design object, and perform output to superimpose the design object at the calculated position.
Claims
1. An image processing apparatus comprising: a processor configured to: receive an image having a foreground segment and a background segment; receive a design object; obtain a centroid position of the foreground segment, and obtain a centroid position of the design object on a basis of the centroid position of the foreground segment; calculate a position for superimposing the design object, on a basis of respective features of the foreground segment, the background segment, and the design object; and perform output to superimpose the design object at the calculated position.
2. The image processing apparatus according to claim 1, wherein the processor obtains the centroid position of the design object to place the centroid position of the design object at a position symmetrical to the centroid position of the foreground segment with respect to a center of the image.
3. The image processing apparatus according to claim 2, wherein the processor obtains the centroid position of the foreground segment with inclusion of a color difference of color of the foreground segment from color of the background segment.
4. The image processing apparatus according to claim 3, wherein the processor obtains the centroid position of the design object with inclusion of a color difference of color of the design object from color of the background segment.
5. The image processing apparatus according to claim 2, wherein the processor obtains the centroid position of the design object with inclusion of a color difference of color of the design object from color of the background segment.
6. The image processing apparatus according to claim 1, wherein the processor obtains the centroid position of the foreground segment with inclusion of a color difference of color of the foreground segment from color of the background segment.
7. The image processing apparatus according to claim 6, wherein the processor obtains the centroid position of the design object with inclusion of a color difference of color of the design object from color of the background segment.
8. The image processing apparatus according to claim 1, wherein the processor obtains the centroid position of the foreground segment with inclusion of a color difference of color of the foreground segment from color of the background segment.
9. The image processing apparatus according to claim 8, wherein the processor obtains the centroid position of the design object with inclusion of a color difference of color of the design object from color of the background segment.
10. The image processing apparatus according to claim 1, wherein the processor obtains the centroid position of the design object with inclusion of a color difference of color of the design object from color of the background segment.
11. The image processing apparatus according to claim 1, wherein the processor calculates the position for superimposing the design object with inclusion of data regarding a type of the foreground segment.
12. The image processing apparatus according to claim 1, wherein the processor calculates the position for superimposing the design object with inclusion of data regarding a type of the design object.
13. The image processing apparatus according to claim 1, wherein when the design object protrudes from the image, the processor moves the design object to superimpose the design object within the image.
14. The image processing apparatus according to claim 1, wherein if the design object overlaps the foreground segment, the processor moves the design object to superimpose the design object within the background segment.
15. The image processing apparatus according to claim 1, wherein the processor receives a first design object and a second design object, calculates a position for superimposing the first design object, on a basis of respective features of the foreground segment, the background segment, and the first design object, and calculates a position for superimposing the second design object, by using the foreground segment having the first design object added to the foreground segment.
16. A non-transitory computer readable medium storing a program causing a computer to execute a process comprising: receiving an image having a foreground segment and a background segment; receiving a design object; obtaining a centroid position of the foreground segment, and obtaining a centroid position of the design object on a basis of the centroid position of the foreground segment; calculating a position for superimposing the design object, on a basis of respective features of the foreground segment, the background segment, and the design object; and performing output to superimpose the design object at the calculated position.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) An exemplary embodiment of the present disclosure will be described in detail based on the following figures, wherein:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(14)
(15)
(16)
(17)
(18)
(19)
DETAILED DESCRIPTION
(20) An exemplary embodiment of the present disclosure will be described in detail with reference to the drawings.
(21)
(22) The image processing apparatus 10 includes a processor 12, a memory 14, a memory device 16, an operation display interface 18, a communication interface 20, and an input interface 22. The processor 12, the memory 14, the memory device 16, the operation display interface 18, the communication interface 20, and the input interface 22 are connected via a bus 24.
(23) The processor 12 performs predetermined processing in accordance with a control program stored in the memory 14. The memory device 16 is composed of, for example, a hard disk and stores required software and data. An operation display 26 is connected to the operation display interface 18. The operation display 26 is provided with a touch panel 28 and a display 30 and is designed to receive operation data from the touch panel 28 and transmit display data to the display 30.
(24) The communication interface 20 is connected to a terminal apparatus and a server via a local area network (LAN) 32, receives an image from the terminal apparatus or the server, and transmits an image to the terminal apparatus or the server. The communication interface 20 may be connected to the terminal apparatus and the server via not only a LAN but also the Internet.
(25) A mouse 34 and a keyboard 36 are connected to the input interface 22. Operation signals and operation data from the mouse 34 and the keyboard 36 are input into the input interface 22.
(26)
(27) The image processing apparatus 10 includes a design object image receiving unit 38 and a design object receiving unit 40.
(28) The design object image receiving unit 38 receives an image having a foreground segment and a background segment. The design object receiving unit 40 receives an image to be superimposed. The design object image receiving unit 38 receives an image stored in the memory device 16 described above, an image transmitted from the terminal apparatus or the server via the communication interface 20, and other images. In addition to the image stored in the memory device 16 and the image transmitted from the terminal apparatus or the server via the communication interface 20, the design object receiving unit 40 likewise receives an image formed as a text. The received images include a text, a logo, an illustration, and an image.
(29) As to be described later, a foreground segment/background segment cutout unit 42 cuts out the foreground segment and the background segment of the image received by the design object image receiving unit 38 on the basis of the saliency map of a background segment image.
(30) As to be described later, a foreground-segment-image centroid calculation unit 44 calculates the centroid position of the foreground segment by using the moment on the basis of features such as a color difference between the foreground segment image and the background segment image, a color difference between the design object and the background segment image, and the visual importance regarding the type of the foreground segment.
(31) As to be described later, a design object centroid calculation unit 46 calculates the centroid position of a design object layout space to place the centroid position at a position symmetrical to the centroid position of the foreground segment image with respect to the center of the image.
(32) As to be described later, a design object layout determination unit 48 determines whether the design object to be superimposed at the position calculated by the design object centroid calculation unit 46 is superimposed within the background segment image. For example, the design object layout determination unit 48 determines whether the design object protrudes from a design object image or overlaps the foreground segment image.
(33) As to be described later, when the design object layout determination unit 48 determines that the design object is not superimposed within the background segment image, a design object layout changing unit 50 changes the layout of the design object to superimpose the design object within the background segment image.
(34) A result display controller 52 performs control to cause the above-described display to display a state where the design object is superimposed on the background segment image.
(35) As to be described later, an importance database 54 is a database storing visual importance of each image set in advance on a per image type basis.
(36) Forming the saliency map of the background segment image by the foreground segment/background segment cutout unit 42 will be described.
(37)
(38) In subsequent step S12, a histogram representing the frequency of each of pixel values of the original image with the reduced colors is extracted. In subsequent step S14, what are represented by the respective pixel values of R, G, B channels in the histogram extracted in step S12 and pixel values called an alpha channel representing transparency are extracted.
(39) In subsequent step S16, what bright pixel values represent is extracted for a saliency map by using a predetermined threshold. After the saliency map is extracted, a foreground segment and a background segment may be separated from each other as illustrated in
(40) A method for calculating the centroid of a foreground segment image performed by the foreground-segment-image centroid calculation unit 44 will be described.
(41) Formula (1) is a general expression for calculating the physical centroid position in the xy-Cartesian coordinate system.
(42)
(43) The centroid position is obtained by dividing the first moment by the zero-th moment.
(44) Adding elements that are a color difference and importance in obtaining the centroid position results in Formula (2).
f(x,y)=α.sub.x,yw(x,y) (2)
(45) Note that w(x,y) is a color difference between the foreground segment and the background segment, and α.sub.x,y is a coefficient representing importance set in advance in accordance with the type of the foreground segment image.
(46) Formula (3) is used to calculate w(x,y).
w(x,y)=√{square root over ((R.sub.x,y−R.sub.bg).sup.2+(G.sub.x,y−G.sub.bg).sup.2+(B.sub.x,y−B.sub.bg).sup.2)} (3)
(47) R.sub.x,y, G.sub.x,y, and B.sub.x,y are respectively RGB values of each of pixels of the foreground segment image in the RGB color space, R.sub.bg, G.sub.bg, and B.sub.bg are respectively RGB mean values of the background segment in the RGB color space (hereinafter, referred to as a main color).
(48) Note that the color space is not limited to the RGB color space, and HSV and Lab color spaces may be used.
(49) If the foreground segment image includes a logo or a text as a design object, calculation is performed in such a manner as in Formula (4).
(50)
(51) Note that center.sub.img is the center of the original image; α.sub.img, the importance of a foreground segment image; α.sub.text, the importance of the text; α.sub.logo, the importance of the logo; w.sub.img, a color difference of an image; w.sub.text, a color difference of the text; and w.sub.logo, a color difference of the logo.
(52)
(53) The flow of operations performed by the processor 12 described above will be described.
(54)
(55) First, in step S20, a saliency map of the design object image is extracted. In subsequent step S22, the salient area is decided, and a foreground segment and a background segment are cut out. The foreground segment and the background segment thus cut out are temporarily stored with layers separated as a foreground segment image layer 56 and a background segment image layer 58 as illustrated in
(56) In subsequent step S24, the centroid position of the foreground segment image is calculated on the basis of a color difference between the foreground segment and the background segment by using Formulas (1) and (2) described above. In subsequent step S26, the respective types of a design object and the foreground segment are recognized, and importance coefficients are read out from the importance database 54.
(57) In subsequent step S28, the centroid position of the design object is calculated to place the centroid position at a position symmetrical to the centroid position of the foreground segment with respect to the center of the image.
(58) In subsequent steps S30 and S32, whether the design object overlaps the foreground segment image and whether the design object protrudes from the background segment image are respectively determined. If it is determined in step S30 that the design object does not overlap the foreground segment image, or if it is determined in step S32 that the design object does not protrude from the background segment image, the processing proceeds to step S34, an image having the design object superimposed therein is displayed, and then the processing is terminated. That is, as illustrated in
(59) In contrast, if it is determined in step S30 that the design object overlaps the foreground segment image, the processing proceeds to step S36. In step S36, the design object is moved toward a free space along a centroid symmetrical line (a line connecting the centroid of the foreground segment image and the centroid of the design object across the center of the image). If it is determined in step S32 that the design object protrudes from the background segment, the processing proceeds to step S38. In step S38, the design object is moved toward the inside of the background segment along the centroid symmetrical line.
(60) In subsequent step S40, it is determined whether there is a free space to superimpose the design object. If it is determined in step S40 that there is a free space to superimpose the design object, the processing proceeds to step S34, an image having the design object is displayed, and then the processing is terminated.
(61) If it is determined that there is not a free space in step S40, the processing proceeds to step S42, a search for a free space in the second stage is performed. Specifically, as illustrated in
(62) Examples according to the present disclosure will be described.
(63)
(64) In Example 1, as illustrated in
(65) The foreground segment image is regarded as a building, and the main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image is obtained as follows.
(66) The main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image=(181, 195, 206)
(67) The centroid of the foreground segment image is obtained by using a color difference w(x,y) between the RGB data of pixels (x, y) of the foreground segment image and the RGB data regarding the main color of the background segment image in accordance with Formulas (1), (2), and (3) described above.
(68) As the result of this, the centroid position of the foreground segment image (x.sub.fg, y.sub.fg) is obtained as follows.
(69) The centroid position of the foreground segment image (x.sub.fg, y.sub.fg)=(228, 237)
(70) The center (x.sub.imgC, y.sub.imgC) of the original image=(151, 180) is also obtained.
(71) The importance of the building and the text is as follows.
(72) The importance of the building α.sub.fg=0.05
(73) The importance of the text α.sub.txt=1.0
(74) If the design object is input as an image, the design object is converted to a text, and then the importance thereof is set.
(75) As illustrated in
(76)
(77) As the result, as illustrated in
(78) The centroid position of the design object (x.sub.txt, y.sub.txt)=(59, 112)
(79)
(80) In Example 2, as illustrated in
(81) The foreground segment image is recognized as a building, and the main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image is obtained as follows.
(82) The main color of the background segment image (R.sub.bg, G.sub.bg, B.sub.bg)=(167, 203, 204)
(83) Calculating the centroid position of the foreground segment image in the same manner as in Example 1 results in the following.
(84) The centroid position of the foreground segment image (x.sub.fg, y.sub.fg)=(215, 192)
(85) The center of the original image (x.sub.imgC, y.sub.imgC)=(180, 155) is also obtained.
(86) The importance of the building and the text is as follows.
(87) The importance of the building α.sub.fg=0.05
(88) The importance of the text α.sub.txt=1.0
(89) Calculating the centroid position of the design object in the same manner as in Example 1 results in the following.
(90) The centroid position of the design object (x.sub.txt, y.sub.txt)=(141, 41)
(91) As the result, the design object protrudes from the original image as illustrated in
(92) Accordingly, the design object is moved along the centroid line as described above with reference to step S38, and the design object is thus superimposed within the background segment image at the following position.
(93) The moved centroid position of the design object (x.sub.txt, y.sub.txt)=(145, 51)
(94)
(95) In Example 3, as illustrated in
(96) The foreground segment image is recognized as an animal, and the main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image is obtained as follows.
(97) The main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image=(184, 199, 216)
(98) Calculating the centroid position of the foreground segment image in the same manner as in Example 1 results in the following.
(99) The centroid position of the foreground segment image (x.sub.fg, y.sub.fg)=(221, 180)
(100) The center (x.sub.imgC, y.sub.imgC) of the original image=(180, 119) is also obtained.
(101) The importance of the building and the text is as follows.
(102) The importance of the animal α.sub.fg=0.1
(103) The importance of the text α.sub.txt=1.0
(104) Calculating the centroid position of the design object in the same manner as in Example 1 results in the following.
(105) The centroid position of the design object (x.sub.txt, y.sub.txt)=(131, 47)
(106) As the result, the design object overlaps the foreground segment image as illustrated in
(107) Accordingly, the design object is moved along the centroid line as described above with reference to step S36, and the design object does not overlap the foreground segment image at the following position.
(108) The moved centroid position of the design object (x.sub.txt, y.sub.txt)=(34, 21)
(109)
(110) In Example 4, as illustrated in
(111) The foreground segment image is regarded as a person, and the main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image is obtained as follows.
(112) The main color (R.sub.bg, G.sub.bg, B.sub.bg) of the background segment image=(200, 198, 207)
(113) Calculating the centroid position of the foreground segment image in the same manner as in Example 1 results in the following.
(114) The centroid position of the foreground segment image (x.sub.fg, y.sub.fg)=(166, 142)
(115) The center (x.sub.imgC, y.sub.imgC) of the original image=(180, 120) is also obtained.
(116) The importance coefficients of the person, the illustration, and text are extracted, and the illustration is first superimposed on the background segment image.
(117) The illustration layout space overlaps the foreground segment image, and the centroid of the illustration is moved to a free space in an adjacent area as illustrated in
(118) The centroid position of the illustration (x.sub.illus, y.sub.illus)=(238, 90)
(119) Subsequently, the text is superimposed on the background segment image. At this time, the illustration is included in and handled as a design object image. Specifically, the centroid position of the foreground segment image is calculated with the illustration being included in the foreground segment image.
(120) As the result of re-calculation, a new foreground segment centroid position is obtained as follows.
(121) The new foreground segment centroid position (x.sub.fg, y.sub.fg)=(185, 110)
(122) After the centroid position to superimpose the text is calculated on the basis of the new foreground segment centroid position, the text layout space overlaps the foreground segment image as illustrated in
(123) The centroid position of the text (x.sub.txt, y.sub.txt)=(74, 110)
(124)
(125) Example 5 is an example where a text is to be superimposed and where not only the size (width and height) but also the color of the text is changed.
(126) Specifically,
(127) When the size of the text is increased by using the text size designation section 64, and when the text color is made darker by using the text color designation section 66, the state in
(128) In this case, the size of the text is increased, and a color difference between the text and the background segment image is thus increased. Accordingly, the weight of the text is increased, and thus the text moves to the center of the screen.
(129) In the embodiment above, the term “processor” refers to hardware in a broad sense. Examples of the processor include general processors (e.g., CPU: Central Processing Unit), dedicated processors (e.g., GPU: Graphics Processing Unit, ASIC: Application Specific Integrated Circuit, FPGA: Field Programmable Gate Array, and programmable logic device).
(130) In the embodiment above, the term “processor” is broad enough to encompass one processor or plural processors in collaboration which are located physically apart from each other but may work cooperatively. The order of operations of the processor is not limited to one described in the embodiment above, and may be changed.
(131) The foregoing description of the exemplary embodiment of the present disclosure has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the disclosure to the precise forms disclosed. Obviously, many modifications and variations will be apparent to practitioners skilled in the art. The embodiment was chosen and described in order to best explain the principles of the disclosure and its practical applications, thereby enabling others skilled in the art to understand the disclosure for various embodiments and with the various modifications as are suited to the particular use contemplated. It is intended that the scope of the disclosure be defined by the following claims and their equivalents.