19 auto fimage = std::make_shared<Image>();
29 std::vector<float> xx(intrinsic.
width_);
30 std::vector<float> yy(intrinsic.
height_);
31 for (
int j = 0; j < intrinsic.
width_; j++) {
32 xx[j] = (j - fpp[0]) * ffl_inv[0];
34 for (
int i = 0; i < intrinsic.
height_; i++) {
35 yy[i] = (i - fpp[1]) * ffl_inv[1];
37 for (
int i = 0; i < intrinsic.
height_; i++) {
39 (
float *)(fimage->data_.data() + i * fimage->BytesPerLine());
40 for (
int j = 0; j < intrinsic.
width_; j++, fp++) {
41 *fp = sqrtf(xx[j] * xx[j] + yy[i] * yy[i] + 1.0f);
49 auto fimage = std::make_shared<Image>();
55 float *p = (
float *)(fimage->data_.data() + i * 4);
61 *p = (
float)(*pi) / 255.0f;
63 const uint16_t *pi16 = (
const uint16_t *)pi;
66 const float *pf = (
const float *)pi;
76 *p = (0.2990f * (
float)(pi[0]) + 0.5870f * (
float)(pi[1]) +
77 0.1140f * (
float)(pi[2])) /
81 const uint16_t *pi16 = (
const uint16_t *)pi;
88 *p = (0.2990f * (
float)(pi16[0]) +
89 0.5870f * (
float)(pi16[1]) +
90 0.1140f * (
float)(pi16[2]));
93 const float *pf = (
const float *)pi;
95 *p = (pf[0] + pf[1] + pf[2]) / 3.0f;
98 *p = (0.2990f * pf[0] + 0.5870f * pf[1] + 0.1140f * pf[2]);
106 template <
typename T>
108 auto output = std::make_shared<Image>();
111 "[CreateImageFromFloatImage] Unsupported image format.");
115 const float *pi = (
const float *)
data_.data();
116 T *p = (T *)output->data_.data();
118 if (
sizeof(T) == 1) *p =
static_cast<T
>(*pi * 255.0f);
119 if (
sizeof(T) == 2) *p =
static_cast<T
>(*pi);
124 template std::shared_ptr<Image> Image::CreateImageFromFloatImage<uint8_t>()
126 template std::shared_ptr<Image> Image::CreateImageFromFloatImage<uint16_t>()
130 bool with_gaussian_filter )
const {
131 std::vector<std::shared_ptr<Image>> pyramid_image;
132 pyramid_image.clear();
137 for (
size_t i = 0; i < num_of_levels; i++) {
139 std::shared_ptr<Image> input_copy_ptr = std::make_shared<Image>();
140 *input_copy_ptr = *
this;
141 pyramid_image.push_back(input_copy_ptr);
143 if (with_gaussian_filter) {
145 auto level_b = pyramid_image[i - 1]->Filter(
147 auto level_bd = level_b->Downsample();
148 pyramid_image.push_back(level_bd);
150 auto level_d = pyramid_image[i - 1]->Downsample();
151 pyramid_image.push_back(level_d);
155 return pyramid_image;
Contains the pinhole camera intrinsic parameters.
int height_
Height of the image.
int width_
Width of the image.
std::pair< double, double > GetFocalLength() const
Returns the focal length in a tuple of X-axis and Y-axis focal lengths.
std::pair< double, double > GetPrincipalPoint() const
virtual bool IsEmpty() const override
ColorToIntensityConversionType
Specifies whether R, G, B channels have the same weight when converting to intensity....
@ Weighted
Weighted R, G, B channels: I = 0.299 * R + 0.587 * G + 0.114 * B.
@ Equal
R, G, B channels have equal weights.
int num_of_channels_
Number of chanels in the image.
std::shared_ptr< Image > CreateFloatImage(Image::ColorToIntensityConversionType type=Image::ColorToIntensityConversionType::Weighted) const
Return a gray scaled float type image.
int height_
Height of the image.
int bytes_per_channel_
Number of bytes per channel.
int width_
Width of the image.
std::vector< uint8_t > data_
Image storage buffer.
std::shared_ptr< Image > CreateImageFromFloatImage() const
ImagePyramid CreatePyramid(size_t num_of_levels, bool with_gaussian_filter=true) const
Function to create image pyramid.
@ Gaussian3
Gaussian filter of size 3 x 3.
static std::shared_ptr< Image > CreateDepthToCameraDistanceMultiplierFloatImage(const camera::PinholeCameraIntrinsic &intrinsic)
std::vector< std::shared_ptr< Image > > ImagePyramid
Typedef and functions for ImagePyramid.
Generic file read and write utility for python interface.