18 #ifndef PIC_ALGORITHMS_GROW_CUT_HPP 19 #define PIC_ALGORITHMS_GROW_CUT_HPP 21 #include "../base.hpp" 23 #include "../image.hpp" 24 #include "../image_vec.hpp" 26 #include "../util/std_util.hpp" 28 #include "../filtering/filter_max.hpp" 29 #include "../filtering/filter_grow_cut.hpp" 30 #include "../filtering/filter_channel.hpp" 71 return (img->
channels != channels) ||
72 (img->
width != width) ||
102 float red[] = {1.0f, 0.0f, 0.0f};
103 float blue[] = {0.0f, 0.0f, 1.0f};
105 for(
int i = 0; i < strokes->
nPixels(); i++) {
113 out->
data[i] = d_red < 0.5f ? 1.0f : out->
data[i];
114 out->
data[i] = d_blue < 0.5f ? -1.0f : out->
data[i];
151 auto seeds = imgIn[1];
154 imgOut =
new Image(img->width, img->height, 2);
157 imgOut =
new Image(img->width, img->height, 2);
161 auto state_cur = imgOut;
166 if(
checkImage(state_cur, img->width, img->height, 2)) {
174 for(
int i = 0; i < state_cur->nPixels(); i++) {
177 int j_seeds = i * seeds->channels;
178 state_cur->data[j] = seeds->data[j_seeds];
179 state_cur->data[j + 1] = fabsf(seeds->data[j_seeds]) > 0.0f ? 1.0f : 0.0f;
187 int iterations = int(img->getDiagonalSize());
189 if((iterations % 2) == 1) {
196 for(
int i = 0; i < iterations; i++) {
199 Image *tmp = input[0];
FilterMax * fltMax
Definition: grow_cut.hpp:38
PIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)
ImageVecCheck.
Definition: image_vec.hpp:147
Image * state_next
Definition: grow_cut.hpp:39
GrowCut()
GrowCut.
Definition: grow_cut.hpp:46
int channels
Definition: filter_radial_basis_function.hpp:80
~GrowCut()
Definition: grow_cut.hpp:54
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
static Image * execute(Image *imgIn, Image *imgOut, int channel=0)
execute
Definition: filter_channel.hpp:131
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
static T distanceSq(T *data0, T *data1, int n)
distanceSq
Definition: array.hpp:195
int nPixels() const
nPixels computes the number of pixels.
Definition: image.hpp:499
static Image * fromStrokeImageToSeeds(Image *strokes, Image *out)
fromStrokeImageToSeeds
Definition: grow_cut.hpp:82
PIC_INLINE ImageVec Double(Image *img1, Image *img2)
Double creates an std::vector which contains img1 and img2; this is for filters input.
Definition: image_vec.hpp:49
Image * img_max
Definition: grow_cut.hpp:39
Definition: grow_cut.hpp:34
static Image * getMaskAsImage(Image *state, Image *out)
getMaskAsImage
Definition: grow_cut.hpp:125
The FilterGrowCut class.
Definition: filter_grow_cut.hpp:29
FilterGrowCut flt
Definition: grow_cut.hpp:37
The FilterMax class.
Definition: filter_max.hpp:28
The Image class stores an image as buffer of float.
Definition: image.hpp:60
PIC_INLINE ImageVec Triple(Image *img1, Image *img2, Image *img3)
Triple creates an std::vector which contains img1, img2, and img3; this is for filters input...
Definition: image_vec.hpp:64
static Image * execute(Image *img, Image *seeds, Image *imgOut)
Definition: grow_cut.hpp:207
Image * allocateSimilarOne()
allocateSimilarOne creates an Image with similar size of the calling instance.
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Definition: bilateral_separation.hpp:25
Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: grow_cut.hpp:144
static T norm_sq(float *data, int n)
norm_sq
Definition: array.hpp:227
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
static bool checkImage(Image *img, int width, int height, int channels)
checkImage
Definition: grow_cut.hpp:69