Compositor: add new node: Kuwahara filter #107015
|
@ -55,42 +55,33 @@ int KuwaharaOperation::get_variation()
|
|||
return variation_;
|
||||
}
|
||||
|
||||
|
||||
void KuwaharaOperation::update_memory_buffer(MemoryBuffer *output,
|
||||
void KuwaharaOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
MemoryBuffer *image = inputs[0];
|
||||
|
||||
const int bwidth = area.xmax - area.xmin;
|
||||
const int bheight = area.ymax - area.ymin;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const int x = it.x;
|
||||
const int y = it.y;
|
||||
it.out[3] = image->get_value(x, y, 3);
|
||||
|
||||
for (int y = 0; y < bheight; y++)
|
||||
{
|
||||
for (int x = 0; x < bwidth; x++)
|
||||
{
|
||||
output->get_value(x, y, 3) = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
for (int y = 0; y < bheight; y++)
|
||||
{
|
||||
for (int x = 0; x < bwidth; x++)
|
||||
for(int ch = 0; ch < 3; ch++)
|
||||
{
|
||||
float sum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float var[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
int cnt[4] = {0, 0, 0, 0};
|
||||
|
||||
for (int dy = -kernel_size_; dy <= kernel_size_; dy++)
|
||||
{
|
||||
for (int dx = -kernel_size_; dx <= kernel_size_; dx++)
|
||||
{
|
||||
|
||||
int xx = x + dx;
|
||||
int yy = y + dy;
|
||||
if (xx >= 0 && yy >= 0 && xx < area.xmax && yy < area.ymax)
|
||||
|
||||
{
|
||||
//double v = temp.at<float>(yy, xx * dim + c);
|
||||
float v;
|
||||
v = image->get_value(xx, yy, ch);
|
||||
|
||||
|
@ -140,14 +131,6 @@ void KuwaharaOperation::update_memory_buffer(MemoryBuffer *output,
|
|||
output->get_value(x, y, ch) = res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KuwaharaOperation::get_area_of_interest(const int /*input_idx*/,
|
||||
const rcti & /*output_area*/,
|
||||
rcti &r_input_area)
|
||||
{
|
||||
r_input_area = this->get_canvas();
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_MultiThreadedOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class KuwaharaOperation : public NodeOperation {
|
||||
class KuwaharaOperation : public MultiThreadedOperation {
|
||||
SocketReader *image_reader_;
|
||||
|
||||
int kernel_size_;
|
||||
|
@ -26,22 +26,10 @@ class KuwaharaOperation : public NodeOperation {
|
|||
void set_variation(int variation);
|
||||
int get_variation();
|
||||
|
||||
void update_memory_buffer(MemoryBuffer *output,
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs) override;
|
||||
|
||||
void get_area_of_interest(const int input_idx,
|
||||
const rcti & output_area,
|
||||
rcti &r_input_area) override;
|
||||
//
|
||||
// bool determine_depending_area_of_interest(rcti *input,
|
||||
// ReadBufferOperation *read_operation,
|
||||
// rcti *output) override;
|
||||
//
|
||||
// void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
// const rcti &area,
|
||||
// Span<MemoryBuffer *> inputs) override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
|
|
@ -30,7 +30,7 @@ static void node_composit_init_kuwahara(bNodeTree * /*ntree*/, bNode *node)
|
|||
NodeKuwaharaData *data = MEM_cnew<NodeKuwaharaData>(__func__);
|
||||
node->storage = data;
|
||||
|
||||
data->kernel_size = 4.1f;
|
||||
data->kernel_size = 4;
|
||||
}
|
||||
|
||||
static void node_composit_buts_kuwahara(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
|
|
Loading…
Reference in New Issue
Suggest using early
continue
and un-indent the block.