Lagrange
Loading...
Searching...
No Matches
image_sampling.h
1/*
2 * Copyright 2022 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/common.h>
15#include <lagrange/image/ImageView.h>
16#include <lagrange/image/api.h>
17
18namespace lagrange {
19namespace image {
20
32LA_IMAGE_API void sample_from_density_map(
33 const image::ImageView<float>& density_map,
34 size_t n_samples,
35 lagrange::Vertices2Df& samples);
36
40enum class SampleType {
43};
44
58LA_IMAGE_API void sample_borders(
59 const image::ImageView<float>& density_map,
60 size_t n_samples,
61 lagrange::Vertices2Df& samples,
63
73LA_IMAGE_API void density_sample_borders(
74 const image::ImageView<float>& density_map,
75 size_t n_samples,
76 lagrange::Vertices2Df& samples);
77
78
89LA_IMAGE_API void regular_sample_borders(
90 const image::ImageView<float>& density_map,
91 size_t n_samples,
92 lagrange::Vertices2Df& samples);
93
102LA_IMAGE_API float bilinear_interpolation(const image::ImageView<float>& image, float x, float y);
103
120LA_IMAGE_API float
122
123
144LA_IMAGE_API float
145percentile(const image::ImageView<float>& image, const float x, const int num_bins = 1000);
146
147} // namespace image
148} // namespace lagrange
Definition ImageView.h:56
Basic image data structure.
LA_IMAGE_API void density_sample_borders(const image::ImageView< float > &density_map, size_t n_samples, lagrange::Vertices2Df &samples)
Populates a list of n_samples sample according to the density of the border pixeslin density_map.
Definition image_sampling.cpp:116
LA_IMAGE_API float bilinear_interpolation(const image::ImageView< float > &image, float x, float y)
Samples a single point from the input image using bilinear interpolation.
Definition image_sampling.cpp:209
LA_IMAGE_API float nearest_neighbor_interpolation(const image::ImageView< float > &image, float x, float y)
Performs nearest neighbor interpolation on an image.
Definition image_sampling.cpp:229
LA_IMAGE_API float percentile(const image::ImageView< float > &image, const float x, const int num_bins=1000)
Calculate an approximation of the x-th percentile of an image using a histogram.
Definition image_sampling.cpp:245
LA_IMAGE_API void regular_sample_borders(const image::ImageView< float > &density_map, size_t n_samples, lagrange::Vertices2Df &samples)
Populates a list of approximately n_samples sample points with integer coordinates,...
Definition image_sampling.cpp:84
SampleType
Type of sampling to use.
Definition image_sampling.h:40
@ Density
sample according to density map
Definition image_sampling.h:41
@ Regular
sample regularly (ignores density)
Definition image_sampling.h:42
LA_IMAGE_API void sample_from_density_map(const image::ImageView< float > &density_map, size_t n_samples, lagrange::Vertices2Df &samples)
Populates a list of approximately n_samples sample points with integer coordinates ranging from (0,...
Definition image_sampling.cpp:23
LA_IMAGE_API void sample_borders(const image::ImageView< float > &density_map, size_t n_samples, lagrange::Vertices2Df &samples, SampleType type=SampleType::Regular)
Populates a list of n_samples samples with samples along the image borders.
Definition image_sampling.cpp:70
Main namespace for Lagrange.