Method and device for correcting image, electronic equipment, and storage medium
A first image collected by an image collector is acquired. A map generated based on a correspondence between a distortion rate and a field of view of the image collector is acquired. The map includes a mapping relation between a raw pixel coordinate of a pixel in a raw image collected by the image collector and a target pixel coordinate that has been corrected. A second image that has been corrected is acquired by correcting the first image based on the map.
1. A method for correcting an image, comprising:
acquiring a first image collected by an image collector;
acquiring a map generated based on a correspondence between a distortion rate and a field of view of the image collector, the map comprising a mapping relation between a raw pixel coordinate of a pixel in a raw image collected by the image collector and a target pixel coordinate that has been corrected; and
acquiring a second image that has been corrected by correcting the first image based on the map,
wherein the map is generated by:
acquiring the correspondence, the correspondence comprising N discrete field-of-view-to-distortion-rate mapping relations of the image collector, the N being a positive integer greater than or equal to 2;
generating a Field Distortion (FD) curve based on an interpolation algorithm and the correspondence, the FD curve being configured for determining a distortion rate corresponding to a field of view where a raw pixel coordinate in an image collected by the image collector is located; and
generating the map based on the FD curve, a first distance, and a second distance, the first distance being a distance between the raw pixel coordinate and a center of the image, the second distance being a distance between the target pixel coordinate and the center.
2. The method of claim 1 , wherein acquiring the map generated based on the correspondence between the distortion rate and the field of view of the image collector comprises:
reading the map, wherein the map is generated in advance based on the correspondence between the distortion rate and the field of view of the image collector.
3. The method of claim 1 , wherein generating the map based on the FD curve, the first distance, and the second distance comprises:
determining the field of view of the raw pixel coordinate of the image collector;
determining the distortion rate of the raw pixel coordinate by searching the FD curve based on the field of view;
determining the target pixel coordinate corresponding to the raw pixel coordinate of the image collector based on a functional relation among the distortion rate, the first distance, and the second distance; and
generating the map based on the raw pixel coordinate and the target pixel coordinate corresponding to the raw pixel coordinate.
4. The method of claim 3 , wherein determining the field of view of the raw pixel coordinate of the image collector comprises:
determining a maximum collection radius and a pixel coordinate of a center of the image collector, a field of view of the pixel coordinate of the center being a first preset value, a field of view of a predetermined pixel coordinate being a second preset value, the predetermined pixel coordinate being: a pixel coordinate with a distance to the pixel coordinate of the center of the image collector equal to the maximum collection radius, a difference between the second preset value and the first preset value being a field-of-view range of the image collector;
determining a distance between the raw pixel coordinate collected by the image collector and the pixel coordinate of the center of the image collector;
determining a field-of-view ratio of the raw pixel coordinate according to the distance between the raw pixel coordinate and the center of the image collector as well as the maximum collection radius; and
determining the field of view of the raw pixel coordinate based on the field-of-view ratio and the field-of-view range.
5. The method of claim 2 , wherein generating the map based on the FD curve, the first distance, and the second distance comprises:
determining the field of view of the raw pixel coordinate of the image collector;
determining the distortion rate of the raw pixel coordinate by searching the FD curve based on the field of view;
determining the target pixel coordinate corresponding to the raw pixel coordinate of the image collector based on a functional relation among the distortion rate, the first distance, and the second distance; and
generating the map based on the raw pixel coordinate and the target pixel coordinate corresponding to the raw pixel coordinate.
6. The method of claim 5 , wherein determining the field of view of the raw pixel coordinate of the image collector comprises:
determining a maximum collection radius and a pixel coordinate of a center of the image collector, a field of view of the pixel coordinate of the center being a first preset value, a field of view of a predetermined pixel coordinate being a second preset value, the predetermined pixel coordinate being: a pixel coordinate with a distance to the pixel coordinate of the center of the image collector equal to the maximum collection radius, a difference between the second preset value and the first preset value being a field-of-view range of the image collector;
determining a distance between the raw pixel coordinate collected by the image collector and the pixel coordinate of the center of the image collector;
determining a field-of-view ratio of the raw pixel coordinate according to the distance between the raw pixel coordinate and the center of the image collector as well as the maximum collection radius; and
determining the field of view of the raw pixel coordinate based on the field-of-view ratio and the field-of-view range.
7. Electronic device, comprising:
a memory configured to store processor executable instructions; and
a processor connected to the memory,
wherein the processor is configured to perform acts comprising:
acquiring a first image collected by an image collector;
acquiring a map generated based on a correspondence between a distortion rate and a field of view of the image collector, the map comprising a mapping relation between a raw pixel coordinate of a pixel in a raw image collected by the image collector and a target pixel coordinate that has been corrected; and
acquiring a second image that has been corrected by correcting the first image based on the map,
wherein the map is generated by:
acquiring the correspondence, the correspondence comprising N discrete field-of-view-to-distortion-rate mapping relations of the image collector, the N being a positive integer greater than or equal to 2;
generating a Field Distortion (FD) curve based on an interpolation algorithm and the correspondence, the FD curve being configured for determining a distortion rate corresponding to a field of view where a raw pixel coordinate in an image collected by the image collector is located; and
generating the map based on the FD curve, a first distance, and a second distance, the first distance being a distance between the raw pixel coordinate and a center of the image, the second distance being a distance between the target pixel coordinate and the center.
8. The electronic device of claim 7 , wherein the processor is configured to acquire the map generated based on the correspondence between the distortion rate and the field of view of the image collector by:
reading the map, wherein the map is generated in advance based on the correspondence between the distortion rate and the field of view of the image collector.
9. The electronic device of claim 7 , wherein the processor is configured to generate the map based on the FD curve, the first distance, and the second distance by:
determining the field of view of the raw pixel coordinate of the image collector;
determining the distortion rate of the raw pixel coordinate by searching the FD curve based on the field of view;
determining the target pixel coordinate corresponding to the raw pixel coordinate of the image collector based on a functional relation among the distortion rate, the first distance, and the second distance; and
generating the map based on the raw pixel coordinate and the target pixel coordinate corresponding to the raw pixel coordinate.
10. The electronic device of claim 9 , wherein the processor is configured to determine the field of view of the raw pixel coordinate of the image collector by:
determining a maximum collection radius and a pixel coordinate of a center of the image collector, a field of view of the pixel coordinate of the center being a first preset value, a field of view of a predetermined pixel coordinate being a second preset value, the predetermined pixel coordinate being: a pixel coordinate with a distance to the pixel coordinate of the center of the image collector equal to the maximum collection radius, a difference between the second preset value and the first preset value being a field-of-view range of the image collector;
determining a distance between the raw pixel coordinate collected by the image collector and the pixel coordinate of the center of the image collector;
determining a field-of-view ratio of the raw pixel coordinate according to the distance between the raw pixel coordinate and the center of the image collector as well as the maximum collection radius; and
determining the field of view of the raw pixel coordinate based on the field-of-view ratio and the field-of-view range.
11. The electronic device of claim 8 , wherein the processor is configured to generate the map based on the FD curve, the first distance, and the second distance by:
determining the field of view of the raw pixel coordinate of the image collector;
determining the distortion rate of the raw pixel coordinate by searching the FD curve based on the field of view;
determining the target pixel coordinate corresponding to the raw pixel coordinate of the image collector based on a functional relation among the distortion rate, the first distance, and the second distance; and
generating the map based on the raw pixel coordinate and the target pixel coordinate corresponding to the raw pixel coordinate.
12. The electronic device of claim 11 , wherein the processor is configured to determine the field of view of the raw pixel coordinate of the image collector by:
determining a maximum collection radius and a pixel coordinate of a center of the image collector, a field of view of the pixel coordinate of the center being a first preset value, a field of view of a predetermined pixel coordinate being a second preset value, the predetermined pixel coordinate being: a pixel coordinate with a distance to the pixel coordinate of the center of the image collector equal to the maximum collection radius, a difference between the second preset value and the first preset value being a field-of-view range of the image collector;
determining a distance between the raw pixel coordinate collected by the image collector and the pixel coordinate of the center of the image collector;
determining a field-of-view ratio of the raw pixel coordinate according to the distance between the raw pixel coordinate and the center of the image collector as well as the maximum collection radius; and
determining the field of view of the raw pixel coordinate based on the field-of-view ratio and the field-of-view range.
13. A non-transitory computer-readable storage medium, having stored thereon instructions which when executed by a processor of a computer, allow the computer to perform:
acquiring a first image collected by an image collector;
acquiring a map generated based on a correspondence between a distortion rate and a field of view of the image collector, the map comprising a mapping relation between a raw pixel coordinate of a pixel in a raw image collected by the image collector and a target pixel coordinate that has been corrected; and
acquiring a second image that has been corrected by correcting the first image based on the map,
wherein the map is generated by:
acquiring the correspondence, the correspondence comprising N discrete field-of-view-to-distortion-rate mapping relations of the image collector, the N being a positive integer greater than or equal to 2;
generating a Field Distortion (FD) curve based on an interpolation algorithm and the correspondence, the FD curve being configured for determining a distortion rate corresponding to a field of view where a raw pixel coordinate in an image collected by the image collector is located; and
generating the map based on the FD curve, a first distance, and a second distance, the first distance being a distance between the raw pixel coordinate and a center of the image, the second distance being a distance between the target pixel coordinate and the center.
14. The storage medium of claim 13 , wherein acquiring the map generated based on the correspondence between the distortion rate and the field of view of the image collector comprises:
reading the map, wherein the map is generated in advance based on the correspondence between the distortion rate and the field of view of the image collector.
15. The storage medium of claim 13 , wherein generating the map based on the FD curve, the first distance, and the second distance comprises:
determining the field of view of the raw pixel coordinate of the image collector;
determining the distortion rate of the raw pixel coordinate by searching the FD curve based on the field of view;
determining the target pixel coordinate corresponding to the raw pixel coordinate of the image collector based on a functional relation among the distortion rate, the first distance, and the second distance; and
generating the map based on the raw pixel coordinate and the target pixel coordinate corresponding to the raw pixel coordinate.