Lagrange
image_sampling.h
1/*
2 * Copyright 2023 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
41{
42 Density,
43 Regular
44};
45
59LA_IMAGE_API void sample_borders(
60 const image::ImageView<float>& density_map,
61 size_t n_samples,
62 lagrange::Vertices2Df& samples,
64
74LA_IMAGE_API void density_sample_borders(
75 const image::ImageView<float>& density_map,
76 size_t n_samples,
77 lagrange::Vertices2Df& samples);
78
79
90LA_IMAGE_API void regular_sample_borders(
91 const image::ImageView<float>& density_map,
92 size_t n_samples,
93 lagrange::Vertices2Df& samples);
94
103LA_IMAGE_API float bilinear_interpolation(const image::ImageView<float>& image, float x, float y);
104
121LA_IMAGE_API float nearest_neighbor_interpolation(const image::ImageView<float>& image, float x, float y);
122
123
144LA_IMAGE_API float percentile(const image::ImageView<float>& image, const float x, const int num_bins = 1000);
145
146} // namespace image
147} // namespace lagrange
Definition: ImageView.h:56
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:41
@ Density
sample according to density map
@ Regular
sample regularly (ignores density)
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.
Definition: AABBIGL.h:30