Image processing apparatus, image processing method, program, and recording medium
Provided are an image processing apparatus, an image processing method, a program, and a recording medium for more appropriately extracting an image corresponding to a printed matter from a captured image of the printed matter by solving the above-described problem of the related art. An image processing apparatus that extracts an image corresponding to a printed matter from a captured image includes a processor, in which the processor executes an estimation process of estimating a first range including the printed matter in the captured image by applying a range estimation model constructed by machine learning regarding the printed matter to the captured image.
1 . An image processing apparatus that extracts an image corresponding to a printed matter from a captured image, the image processing apparatus comprising:
a processor,
wherein the processor executes an estimation process of estimating a first range including the printed matter in the captured image by applying a range estimation model constructed by machine learning regarding the printed matter to the captured image,
wherein the processor executes
a setting process of setting, based on the first range, a second range that includes the first range and is wider than the first range, in the captured image, and
a detection process of detecting a specific region of the image corresponding to the printed matter within the second range, and
wherein, in the detection process, the processor executes
a first detection process of detecting a first edge in the captured image by applying an edge detection algorithm to the captured image,
a determination process of setting a target range in which the first edge is one end and the other end is located at a position separated from the first edge by a preset number of pixels, and determining a plurality of second points in the target range in correspondence with a plurality of first points arranged along the first edge at a side of the one end in the target range, based on color information of each of the first point and the second point,
a second detection process of detecting a second edge based on the plurality of second points, and
the processor executes an extraction process of extracting the image corresponding to the printed matter from the captured image based on the detected second edge.
2 . The image processing apparatus according to claim 1 ,
wherein, in the estimation process, the processor estimates the first range by applying the range estimation model constructed by the machine learning regarding an appearance of the printed matter to the captured image.
3 . The image processing apparatus according to claim 2 ,
wherein the appearance is at least one of a size of the printed matter, a shape of the printed matter, or a feature of a print surface of the printed matter.
4 . The image processing apparatus according to claim 1 ,
wherein the processor superimposes an object indicating the specific region of the image corresponding to the printed matter, which is detected in the detection process, on the captured image.
5 . The image processing apparatus according to claim 4 ,
wherein the processor superimposes the object on a live view image as the captured image.
6 . The image processing apparatus according to claim 4 ,
wherein the processor executes an extraction process of extracting the image corresponding to the printed matter from the captured image based on an operation of a user.
7 . The image processing apparatus according to claim 6 ,
wherein the image corresponding to the printed matter is defined by the specific region of the image corresponding to the printed matter or the object.
8 . The image processing apparatus according to claim 1 ,
wherein, in the determination process, the processor executes, for each of the plurality of first points,
a process of obtaining a color difference between a pixel of the first point and a pixel of a target point in the target range while shifting the target point from the first point toward the other end by one pixel, and
a process of determining, as the second point, the target point where the color difference is maximized among the target points where the color difference is equal to or greater than a threshold value.
9 . The image processing apparatus according to claim 1 ,
wherein, in the determination process, the processor determines the plurality of first points on the first edge.
10 . The image processing apparatus according to claim 1 ,
wherein, in a case in which a plurality of the first edges are detected in the first detection process, the processor executes the determination process and the second detection process for each of the plurality of first edges.
11 . The image processing apparatus according to claim 1 ,
wherein, in a case in which a print surface of the printed matter includes a print region on which an image to be printed is printed and a frame region located around the print region, the preset number of pixels is smaller than the number of pixels corresponding to a length of a width of the frame region.
12 . The image processing apparatus according to claim 1 ,
wherein the processor further executes a display process of displaying the captured image on a screen, and
during the execution of the display process, the processor superimposes an object indicating the second edge detected in the second detection process on the captured image.
13 . The image processing apparatus according to claim 1 ,
wherein, in a case in which a dark-colored region exists at a position adjacent to the printed matter in the captured image, the processor
detects a boundary of an image of the dark-colored region located on an opposite side of the printed matter, as the first edge, in the first detection process,
determines the plurality of second points in correspondence with the plurality of first points located on the first edge within the target range including the image of the dark-colored region, in the determination process,
detects the second edge based on the plurality of second points, in the second detection process, and
extracts the image corresponding to the printed matter excluding the image of the dark-colored region from the captured image based on the detected second edge, in the extraction process.
14 . The image processing apparatus according to claim 1 ,
wherein the printed matter is a medium having a print surface on which an image to be printed is printed.
15 . An image processing method of extracting an image corresponding to a printed matter from a captured image, the image processing method comprising:
a step of estimating a first range including the printed matter in the captured image by applying a range estimation model constructed by machine learning regarding the printed matter to the captured image, via the processor,
a step of setting, based on the first range, a second range that includes the first range and is wider than the first range, in the captured image, via the processor; and
a step of detecting a specific region of the image corresponding to the printed matter within the second range, via the processor
wherein, in the step of detecting the specific region of the image corresponding to the printed matter,
the processor detects a first edge in the captured image by applying an edge detection algorithm to the captured image, and
the processor sets a target range in which the first edge is one end and the other end is located at a position separated from the first edge by a preset number of pixels, and determines a plurality of second points in the target range in correspondence with a plurality of first points arranged along the first edge at a side of the one end in the target range, based on color information of each of the first point and the second point, and
the image processing method further includes
a step of detecting a second edge based on the plurality of second points, via the processor, and
a step of extracting the image corresponding to the printed matter from the captured image based on the detected second edge, via the processor.
16 . A non-transitory computer-readable recording medium, the recording medium having a program recorded thereon for causing a computer to execute the step included in the image processing method according to claim 15 .