|
Toshihiro Shimizu |
890ddd |
#include "igs_os_type.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h></math.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h></stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h></string.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdarg.h></stdarg.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <time.h></time.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h></assert.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h></stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <iostream></iostream>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdexcept></stdexcept>
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pri_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pri_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
typedef int int32_t;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h> /* for int32_t */</stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
extern "C" {
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_cv_start(int32_t i32_ys);
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_cv_run(int32_t i32_y);
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_cv_end(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
4aa85c |
extern void pri_funct_set_cp_title(const char *cp_title);
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_msg_ttvr(const char *fmt, ...);
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_msg_vr(const char *fmt, ...);
|
|
Toshihiro Shimizu |
890ddd |
extern void pri_funct_err_bttvr(const char *fmt, ...);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef __cplusplus
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static int32_t pri_param_i32_ysize, pri_param_i32_pos_before;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_cv_start(int32_t i32_ys) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout,
|
|
Shinya Kitaoka |
120a6e |
"0%% 10 20 30 40 50 60 70 80 90 100%%\n");
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "....v....v....v....v....v....v....v....v....v....v\n");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pri_param_i32_ysize = i32_ys;
|
|
Shinya Kitaoka |
120a6e |
pri_param_i32_pos_before = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_cv_run(int32_t i32_y) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_pos_current, ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_pos_current = 50 * (i32_y + 1) / pri_param_i32_ysize;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/******switch (i32_y%4) {
|
|
Shinya Kitaoka |
120a6e |
case 0: (void)fprintf(stdout, "-\b" ); break;
|
|
Shinya Kitaoka |
120a6e |
case 1: (void)fprintf(stdout, "\\\b" ); break;
|
|
Shinya Kitaoka |
120a6e |
case 2: (void)fprintf(stdout, "|\b" ); break;
|
|
Shinya Kitaoka |
120a6e |
case 3: (void)fprintf(stdout, "/\b" ); break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (i32_pos_current == pri_param_i32_pos_before) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = pri_param_i32_pos_before; ii < i32_pos_current; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((ii + 1) < i32_pos_current) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, ".");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "^");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pri_param_i32_pos_before = i32_pos_current;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_cv_end(void) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "\n");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h></string.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdarg.h></stdarg.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <time.h></time.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined _WIN32
|
|
Toshihiro Shimizu |
890ddd |
#define vsnprintf(buf, len, fmt, ap) _vsnprintf(buf, len, fmt, ap)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
4aa85c |
static const char *pri_param_cp_com_name = "#";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_set_cp_title(const char *cp_title) {
|
|
Shinya Kitaoka |
120a6e |
pri_param_cp_com_name = cp_title;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* print Valiable_argument, Return_code */
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_msg_vr(const char *fmt, ...) {
|
|
Shinya Kitaoka |
120a6e |
int i_ret;
|
|
Shinya Kitaoka |
120a6e |
va_list ap;
|
|
Shinya Kitaoka |
120a6e |
char buf[FILENAME_MAX];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
va_start(ap, fmt);
|
|
Shinya Kitaoka |
120a6e |
i_ret = vsnprintf(buf, FILENAME_MAX, fmt, ap);
|
|
Shinya Kitaoka |
120a6e |
va_end(ap);
|
|
Shinya Kitaoka |
120a6e |
if (i_ret < 0) {
|
|
Shinya Kitaoka |
120a6e |
(void)strcpy(buf, "bad argument for fprintf stdout");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "%s\n", buf);
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* print Title, Time_stamp, Valiable_argument, Return_code */
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_msg_ttvr(const char *fmt, ...) {
|
|
Shinya Kitaoka |
120a6e |
time_t tt;
|
|
Shinya Kitaoka |
120a6e |
char *cc;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i_ret;
|
|
Shinya Kitaoka |
120a6e |
va_list ap;
|
|
Shinya Kitaoka |
120a6e |
char buf[FILENAME_MAX];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tt = time(NULL);
|
|
Shinya Kitaoka |
120a6e |
cc = asctime(localtime(&tt));
|
|
Shinya Kitaoka |
120a6e |
cc[24] = '\0'; /* 26-character Example : "Fri Sep 13 00:00:00 1986\n\0" */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
va_start(ap, fmt);
|
|
Shinya Kitaoka |
120a6e |
i_ret = vsnprintf(buf, FILENAME_MAX, fmt, ap);
|
|
Shinya Kitaoka |
120a6e |
va_end(ap);
|
|
Shinya Kitaoka |
120a6e |
if (i_ret < 0) {
|
|
Shinya Kitaoka |
120a6e |
(void)strcpy(buf, "bad argument for fprintf stdout");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "%s %s %s\n", pri_param_cp_com_name, cc, buf);
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* print Bell, Title, Time_stamp, Valiable_argument, Return_code */
|
|
Shinya Kitaoka |
120a6e |
void pri_funct_err_bttvr(const char *fmt, ...) {
|
|
Shinya Kitaoka |
120a6e |
time_t tt;
|
|
Shinya Kitaoka |
120a6e |
char *cc;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int i_ret;
|
|
Shinya Kitaoka |
120a6e |
va_list ap;
|
|
Shinya Kitaoka |
120a6e |
char buf[FILENAME_MAX];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tt = time(NULL);
|
|
Shinya Kitaoka |
120a6e |
cc = asctime(localtime(&tt));
|
|
Shinya Kitaoka |
120a6e |
cc[24] = '\0'; /* 26-character Example : "Fri Sep 13 00:00:00 1986\n\0" */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
va_start(ap, fmt);
|
|
Shinya Kitaoka |
120a6e |
i_ret = vsnprintf(buf, FILENAME_MAX, fmt, ap);
|
|
Shinya Kitaoka |
120a6e |
va_end(ap);
|
|
Shinya Kitaoka |
120a6e |
if (i_ret < 0) {
|
|
Shinya Kitaoka |
120a6e |
(void)strcpy(buf, "bad argument for fprintf stderr");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stderr, "\007%s %s %s\n", pri_param_cp_com_name, cc, buf);
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stderr);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _list_node_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _list_node_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class list_node {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
list_node() {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_previous = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clp_next = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
list_node *get_clp_next(void) { return this->_clp_next; }
|
|
Shinya Kitaoka |
120a6e |
list_node *get_clp_previous(void) { return this->_clp_previous; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void set_clp_next(list_node *clp) { this->_clp_next = clp; }
|
|
Shinya Kitaoka |
120a6e |
void set_clp_previous(list_node *clp) { this->_clp_previous = clp; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
list_node *_clp_previous, *_clp_next;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _list_root_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _list_root_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
typedef int int32_t;
|
|
Toshihiro Shimizu |
890ddd |
typedef unsigned short uint16_t;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h> /* for int32_t, uint16_t */</stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class list_root {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
list_root() {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_first = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clp_last = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
list_node *push(list_node *clp_previous, list_node *clp_new);
|
|
Shinya Kitaoka |
120a6e |
list_node *pop(list_node *clp_old);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
list_node *get_clp_first(void) { return this->_clp_first; }
|
|
Shinya Kitaoka |
120a6e |
list_node *get_clp_last(void) { return this->_clp_last; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_count(void) { return this->_i32_count; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
list_node *_clp_first, *_clp_last;
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_count;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void _set_clp_first(list_node *clp_) { this->_clp_first = clp_; }
|
|
Shinya Kitaoka |
120a6e |
void _set_clp_last(list_node *clp_) { this->_clp_last = clp_; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void _connect(list_node *clp_previous, list_node *clp_next);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void list_root::_connect(list_node *clp_previous, list_node *clp_next) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL == clp_previous) && (NULL == clp_next)) {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_first = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clp_last = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((NULL != clp_previous) && (NULL == clp_next)) {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_last = clp_previous;
|
|
Shinya Kitaoka |
120a6e |
clp_previous->set_clp_next(NULL);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((NULL == clp_previous) && (NULL != clp_next)) {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_first = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next->set_clp_previous(NULL);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((NULL != clp_previous) && (NULL != clp_next)) {
|
|
Shinya Kitaoka |
120a6e |
clp_next->set_clp_previous(clp_previous);
|
|
Shinya Kitaoka |
120a6e |
clp_previous->set_clp_next(clp_next);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
list_node *list_root::push(list_node *clp_previous, list_node *clp_new) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_new);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_previous) {
|
|
Shinya Kitaoka |
120a6e |
this->_connect(clp_new, clp_previous->get_clp_next());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
this->_connect(clp_new, this->get_clp_first());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_connect(clp_previous, clp_new);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++(this->_i32_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return clp_new;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
list_node *list_root::pop(list_node *clp_old) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_old);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_connect(clp_old->get_clp_previous(), clp_old->get_clp_next());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
--(this->_i32_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (this->_i32_count));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return clp_old;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _brush_curve_blur_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _brush_curve_blur_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
typedef int int32_t;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h> /* for int32_t */</stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef OK
|
|
Toshihiro Shimizu |
890ddd |
#define OK (0)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#ifndef NG
|
|
Toshihiro Shimizu |
890ddd |
#define NG (-1)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef CHANNEL_COUNT
|
|
Toshihiro Shimizu |
890ddd |
#define CHANNEL_COUNT (4)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class brush_curve_blur {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
brush_curve_blur(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count = 51;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_subpixel_divide = 2;
|
|
Shinya Kitaoka |
120a6e |
this->_d_effect_area_radius = 25.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_power = 1.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_linepixels = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_xp = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_yp = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel = NULL;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < CHANNEL_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_da_pixel[ii] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~brush_curve_blur(void) { this->mem_free(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool ii) { this->_i_mv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool ii) { this->_i_pv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool ii) { this->_i_cv_sw = ii; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_count(int32_t ii) { this->_i32_count = ii; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_count(void) { return this->_i32_count; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_subpixel_divide(int32_t ii) { this->_i32_subpixel_divide = ii; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_subpixel_divide(void) { return this->_i32_subpixel_divide; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_d_effect_area_radius(double dd) { this->_d_effect_area_radius = dd; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_effect_area_radius(void) { return this->_d_effect_area_radius; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_d_power(double dd) { this->_d_power = dd; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_power(void) { return this->_d_power; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* get for using */
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_linepixels(void) { return this->_dp_linepixels; }
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_xp(void) { return this->_dp_xp; }
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_yp(void) { return this->_dp_yp; }
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_pixel(void) { return this->_da_pixel; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Shinya Kitaoka |
120a6e |
int mem_alloc(void);
|
|
Shinya Kitaoka |
120a6e |
void init_ratio_array(void);
|
|
Shinya Kitaoka |
120a6e |
void set_subpixel_value(int32_t i32_x_sub, int32_t i32_y_sub);
|
|
Shinya Kitaoka |
120a6e |
void set_pixel_value(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save(double d_xp, double d_yp, const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
void debug_print(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw;
|
|
otakuto |
c39a2a |
bool _i_pv_sw;
|
|
otakuto |
c39a2a |
bool _i_cv_sw;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_count;
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
double _d_effect_area_radius;
|
|
Shinya Kitaoka |
120a6e |
double _d_power;
|
|
Shinya Kitaoka |
120a6e |
double *_dp_ratio, *_dp_linepixels, *_dp_xp, *_dp_yp, *_dp_subpixel,
|
|
Shinya Kitaoka |
120a6e |
_da_pixel[CHANNEL_COUNT];
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* pow() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h> /* free(), calloc() */</stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "brush_curve_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_curve_blur::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->_dp_ratio) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("brush_curve_blur::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
free(this->_dp_ratio);
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_linepixels = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_xp = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_yp = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int brush_curve_blur::mem_alloc(void) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_i32_count <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("brush_curve_blur::mem_alloc()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(
|
|
Shinya Kitaoka |
120a6e |
"alloc brush_curve_blur memory ((%d * %d) + %d) x %d bytes",
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count, (1 + CHANNEL_COUNT + 2),
|
|
Shinya Kitaoka |
120a6e |
this->_i32_subpixel_divide * this->_i32_subpixel_divide *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT,
|
|
Shinya Kitaoka |
120a6e |
sizeof(double));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio = (double *)calloc(
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count * (1 + CHANNEL_COUNT + 2) +
|
|
Shinya Kitaoka |
120a6e |
this->_i32_subpixel_divide * this->_i32_subpixel_divide *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT,
|
|
Shinya Kitaoka |
120a6e |
sizeof(double));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL == this->_dp_ratio) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : calloc(-) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_linepixels = this->_dp_ratio + this->_i32_count;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_xp = this->_dp_linepixels + this->_i32_count * CHANNEL_COUNT;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_yp = this->_dp_xp + this->_i32_count;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel = this->_dp_yp + this->_i32_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_curve_blur::init_ratio_array(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
double d_total;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_i32_count <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 1; ii < this->_i32_count / 2; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio[ii] = ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = this->_i32_count / 2; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio[ii] = this->_i32_count - ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/****for (ii = 0; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio[ii] /=
|
|
Shinya Kitaoka |
120a6e |
(double)(this->_i32_count - this->_i32_count/2);
|
|
Shinya Kitaoka |
120a6e |
}****/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio[ii] = pow(this->_dp_ratio[ii], 1.0 / this->_d_power);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_total = 0.0;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
d_total += this->_dp_ratio[ii];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_dp_ratio[ii] /= d_total;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_curve_blur::set_subpixel_value(int32_t i32_x_sub,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_y_sub) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, zz;
|
|
Shinya Kitaoka |
120a6e |
double d_accum;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_i32_count <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < CHANNEL_COUNT; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel[(this->_i32_subpixel_divide * i32_y_sub + i32_x_sub) *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT +
|
|
Shinya Kitaoka |
120a6e |
zz] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_accum = 0.0;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_dp_linepixels[ii * CHANNEL_COUNT + zz] < 0.0) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel[(this->_i32_subpixel_divide * i32_y_sub + i32_x_sub) *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT +
|
|
Shinya Kitaoka |
120a6e |
zz] +=
|
|
Shinya Kitaoka |
120a6e |
this->_dp_linepixels[ii * CHANNEL_COUNT + zz] * this->_dp_ratio[ii];
|
|
Shinya Kitaoka |
120a6e |
d_accum += this->_dp_ratio[ii];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/* 画像をスキャンしているのだから、
|
|
Shinya Kitaoka |
120a6e |
画像の範囲となる値はかならず一つ以上ある */
|
|
Shinya Kitaoka |
120a6e |
assert(0.0 < d_accum);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel[(this->_i32_subpixel_divide * i32_y_sub + i32_x_sub) *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT +
|
|
Shinya Kitaoka |
120a6e |
zz] /= d_accum;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_curve_blur::set_pixel_value(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, zz;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_i32_count <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < CHANNEL_COUNT; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
this->_da_pixel[zz] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_subpixel_divide; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_subpixel_divide; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
this->_da_pixel[zz] +=
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel[(this->_i32_subpixel_divide * yy + xx) *
|
|
Shinya Kitaoka |
120a6e |
CHANNEL_COUNT +
|
|
Shinya Kitaoka |
120a6e |
zz];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
this->_da_pixel[zz] /=
|
|
Shinya Kitaoka |
120a6e |
this->_i32_subpixel_divide * this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "brush_curve_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int brush_curve_blur::save(double d_xp, double d_yp, const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# curve blur count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# curve blur count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->get_i32_count(); ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", d_xp + this->_dp_xp[ii],
|
|
Shinya Kitaoka |
120a6e |
d_yp + this->_dp_yp[ii]) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(avarage x y) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __brush_smudge_circle_h__
|
|
Toshihiro Shimizu |
890ddd |
#define __brush_smudge_circle_h__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
typedef int int32_t;
|
|
Toshihiro Shimizu |
890ddd |
typedef unsigned short uint16_t;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h> /* for int32_t, uint16_t */</stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef OK
|
|
Toshihiro Shimizu |
890ddd |
#define OK (0)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#ifndef NG
|
|
Toshihiro Shimizu |
890ddd |
#define NG (-1)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class brush_smudge_circle {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle() {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_size_by_pixel = 7;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_subpixel_divide = 4;
|
|
Shinya Kitaoka |
120a6e |
this->_d_ratio = 0.85;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_brush = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel_image = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_pixel_image = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~brush_smudge_circle() { this->mem_free(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool ii) { this->_i_mv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool ii) { this->_i_pv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool ii) { this->_i_cv_sw = ii; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_size_by_pixel(int32_t ii) { this->_i32_size_by_pixel = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_subpixel_divide(int32_t ii) { this->_i32_subpixel_divide = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_ratio(double dd) { this->_d_ratio = dd; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_size_by_pixel(void) { return this->_i32_size_by_pixel; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_subpixel_divide(void) { return this->_i32_subpixel_divide; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_ratio(void) { return this->_d_ratio; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void get_dp_area(double d_xp, double d_yp, double *dp_x1, double *dp_y1,
|
|
Shinya Kitaoka |
120a6e |
double *dp_x2, double *dp_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int mem_alloc(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_brush(void) { return this->_dp_brush; }
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_subpixel_image(void) { return this->_dp_subpixel_image; }
|
|
Shinya Kitaoka |
120a6e |
double *get_dp_pixel_image(void) { return this->_dp_pixel_image; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_brush_circle(void);
|
|
Shinya Kitaoka |
120a6e |
void copy_to_brush_from_image(void);
|
|
Shinya Kitaoka |
120a6e |
void exec(void);
|
|
Shinya Kitaoka |
120a6e |
void to_subpixel_from_pixel(double d_x1, double d_y1, double d_x2,
|
|
Shinya Kitaoka |
120a6e |
double d_y2);
|
|
Shinya Kitaoka |
120a6e |
void to_pixel_from_subpixel(double d_x1, double d_y1, double d_x2,
|
|
Shinya Kitaoka |
120a6e |
double d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw;
|
|
otakuto |
c39a2a |
bool _i_pv_sw;
|
|
otakuto |
c39a2a |
bool _i_cv_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_size_by_pixel, _i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
double _d_ratio;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double *_dp_brush, *_dp_subpixel_image, *_dp_pixel_image;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h> /* free(), calloc() */</stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* sqrt() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h> /* memset() */</string.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "brush_smudge_circle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->_dp_brush) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("brush_smudge_circle::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
free(this->_dp_brush);
|
|
Shinya Kitaoka |
120a6e |
this->_dp_brush = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_pixel_image = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel_image = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int brush_smudge_circle::mem_alloc(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_sz;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->mem_free();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_sz = this->_i32_size_by_pixel * this->_i32_subpixel_divide;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("brush_smudge_circle::mem_alloc()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("calloc((%d x %d + %d x %d + %d x %d) x (%d x %d))",
|
|
Shinya Kitaoka |
120a6e |
i32_sz, i32_sz, i32_sz, i32_sz,
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_size_by_pixel + 1),
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_size_by_pixel + 1), sizeof(double), 5);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_brush = (double *)calloc(
|
|
Shinya Kitaoka |
120a6e |
i32_sz * i32_sz + i32_sz * i32_sz +
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_size_by_pixel + 1) * (this->_i32_size_by_pixel + 1),
|
|
Shinya Kitaoka |
120a6e |
sizeof(double) * 5);
|
|
Shinya Kitaoka |
120a6e |
if (NULL == this->_dp_brush) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : calloc(-) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
this->_dp_subpixel_image = this->_dp_brush + i32_sz * i32_sz * 5;
|
|
Shinya Kitaoka |
120a6e |
this->_dp_pixel_image = this->_dp_subpixel_image + i32_sz * i32_sz * 5;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 画像上に置いたブラシの範囲
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| | |
|
|
Shinya Kitaoka |
120a6e |
| + | + |
|
|
Shinya Kitaoka |
120a6e |
| | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| | |
|
|
Shinya Kitaoka |
120a6e |
| + | + |
|
|
Shinya Kitaoka |
120a6e |
| | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| ^ |
|
|
Shinya Kitaoka |
120a6e |
v | v
|
|
Shinya Kitaoka |
120a6e |
*dp_x1 d_xp *dp_x2
|
|
Shinya Kitaoka |
120a6e |
0 1 <---- d_xp,d_yp is pixel position
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
| +0.5
|
|
Shinya Kitaoka |
120a6e |
v
|
|
Shinya Kitaoka |
120a6e |
0 1 2 <---- *dp_x1,*dp_y1,*dp_x2,*dp_y2 is image position
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::get_dp_area(double d_xp, double d_yp, double *dp_x1,
|
|
Shinya Kitaoka |
120a6e |
double *dp_y1, double *dp_x2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_y2) {
|
|
Shinya Kitaoka |
120a6e |
*dp_x1 = d_xp + 0.5 - this->_i32_size_by_pixel / 2.0;
|
|
Shinya Kitaoka |
120a6e |
*dp_x2 = *dp_x1 + this->_i32_size_by_pixel;
|
|
Shinya Kitaoka |
120a6e |
*dp_y1 = d_yp + 0.5 - this->_i32_size_by_pixel / 2.0;
|
|
Shinya Kitaoka |
120a6e |
*dp_y2 = *dp_y1 + this->_i32_size_by_pixel;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ブラシの形を、有効フラグの設定で決める
|
|
Toshihiro Shimizu |
890ddd |
例
|
|
Shinya Kitaoka |
120a6e |
pixel_size 3 x 3
|
|
Shinya Kitaoka |
120a6e |
subpixel_divide 2 x 2
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 5 |
|
|
Shinya Kitaoka |
120a6e |
| | | | |
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 4 |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 3 |
|
|
Toshihiro Shimizu |
890ddd |
center->| | | | i32_size(3*2)
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 2 |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 1 |
|
|
Shinya Kitaoka |
120a6e |
| | | | |
|
|
Shinya Kitaoka |
120a6e |
| + + | + + | + + | 0 |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
0 1 2 3 4 5 <-+
|
|
Shinya Kitaoka |
120a6e |
0 1 2 3 4 5 6 <
|
|
Shinya Kitaoka |
120a6e |
<---- i32_size(3*2) ---->
|
|
Shinya Kitaoka |
120a6e |
^
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
center
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::set_brush_circle(void) {
|
|
Shinya Kitaoka |
120a6e |
double *dp_brush, d_radius, d_tmp;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, i32_size;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_brush = this->_dp_brush;
|
|
Shinya Kitaoka |
120a6e |
i32_size = this->_i32_size_by_pixel * this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radius = i32_size / 2.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < i32_size; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < i32_size; ++xx, dp_brush += 5) {
|
|
Shinya Kitaoka |
120a6e |
d_tmp = sqrt((xx + 0.5 - d_radius) * (xx + 0.5 - d_radius) +
|
|
Shinya Kitaoka |
120a6e |
(yy + 0.5 - d_radius) * (yy + 0.5 - d_radius));
|
|
Shinya Kitaoka |
120a6e |
if (d_tmp < d_radius) {
|
|
Shinya Kitaoka |
120a6e |
dp_brush[4] = 1.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
dp_brush[4] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::copy_to_brush_from_image(void) {
|
|
Shinya Kitaoka |
120a6e |
double *dp_brush, *dp_image;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, zz, i32_size;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_brush = this->_dp_brush;
|
|
Shinya Kitaoka |
120a6e |
dp_image = this->_dp_subpixel_image;
|
|
Shinya Kitaoka |
120a6e |
i32_size = this->_i32_size_by_pixel * this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < i32_size; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < i32_size; ++xx, dp_brush += 5, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
if (0.0 < dp_brush[4]) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 4; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_brush[zz] = dp_image[zz];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* こする
|
|
Shinya Kitaoka |
120a6e |
以前の場所での画像と指定の比率で差分を画像に足し、その画像をブラシに保存
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::exec(void) {
|
|
Shinya Kitaoka |
120a6e |
double *dp_brush, *dp_image;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, zz, i32_size;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_brush = this->_dp_brush;
|
|
Shinya Kitaoka |
120a6e |
dp_image = this->_dp_subpixel_image;
|
|
Shinya Kitaoka |
120a6e |
i32_size = this->_i32_size_by_pixel * this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < i32_size; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < i32_size; ++xx, dp_brush += 5, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
if (0.0 < dp_brush[4]) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 4; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz] += (dp_brush[zz] - dp_image[zz]) * this->_d_ratio;
|
|
Shinya Kitaoka |
120a6e |
dp_brush[zz] = dp_image[zz];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::to_subpixel_from_pixel(double d_x1, double d_y1,
|
|
Shinya Kitaoka |
120a6e |
double d_x2, double d_y2) {
|
|
Shinya Kitaoka |
120a6e |
double d_subsize;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_xsize;
|
|
Shinya Kitaoka |
120a6e |
double *dp_image, *dp_save;
|
|
Shinya Kitaoka |
120a6e |
double d_x, d_y, d_x1floor, d_y1floor, d_xsave, d_ysave;
|
|
Shinya Kitaoka |
120a6e |
int32_t zz;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
d_subsize = 1.0 / this->_i32_subpixel_divide;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_x1floor = floor(d_x1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
d_y1floor = floor(d_y1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
i32_xsize = (int32_t)floor(d_x2 - d_subsize / 2.0) - (int32_t)d_x1floor + 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
dp_image = this->_dp_subpixel_image;
|
|
Shinya Kitaoka |
120a6e |
dp_save = this->_dp_pixel_image;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (d_y = d_y1 + d_subsize / 2.0; d_y < d_y2; d_y += d_subsize) {
|
|
Shinya Kitaoka |
120a6e |
for (d_x = d_x1 + d_subsize / 2.0; d_x < d_x2;
|
|
Shinya Kitaoka |
120a6e |
d_x += d_subsize, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
d_xsave = d_x - d_x1floor;
|
|
Shinya Kitaoka |
120a6e |
d_ysave = d_y - d_y1floor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int32_t)d_xsave);
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int32_t)d_ysave);
|
|
Shinya Kitaoka |
120a6e |
assert((int32_t)d_xsave < (this->_i32_size_by_pixel + 1));
|
|
Shinya Kitaoka |
120a6e |
assert((int32_t)d_ysave < (this->_i32_size_by_pixel + 1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 5; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz] = dp_save[(int32_t)d_ysave * i32_xsize * 5 +
|
|
Shinya Kitaoka |
120a6e |
(int32_t)d_xsave * 5 + zz];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* 切取ったサブピクセル画像を、(元画像へ)保存のためピクセルサイズに縮小
|
|
Shinya Kitaoka |
120a6e |
例えば、元画像の2 x 2ピクセルの任意の位置から切り取ってあるなら、
|
|
Shinya Kitaoka |
120a6e |
復元に3 x 3ピクセルサイズ必要となる。
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| +-|-----+-|-----+ |
|
|
Shinya Kitaoka |
120a6e |
| + | | + | | + | |
|
|
Shinya Kitaoka |
120a6e |
| | | | | | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| +-|-----+ |-----+ |
|
|
Shinya Kitaoka |
120a6e |
| + | | + | | + | |
|
|
Shinya Kitaoka |
120a6e |
| | | | | | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| +-|-----+-|-----+ |
|
|
Shinya Kitaoka |
120a6e |
| + | + | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void brush_smudge_circle::to_pixel_from_subpixel(double d_x1, double d_y1,
|
|
Shinya Kitaoka |
120a6e |
double d_x2, double d_y2) {
|
|
Shinya Kitaoka |
120a6e |
double d_subsize;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_xsize;
|
|
Shinya Kitaoka |
120a6e |
double *dp_image, *dp_save;
|
|
Shinya Kitaoka |
120a6e |
double d_x, d_y, d_x1floor, d_y1floor, d_xsave, d_ysave;
|
|
Shinya Kitaoka |
120a6e |
int32_t zz;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, jj;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_subsize = 1.0 / this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_save = this->_dp_pixel_image;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_size_by_pixel + 1; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < this->_i32_size_by_pixel + 1; ++jj, dp_save += 5) {
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 5; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_save[zz] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_x1floor = floor(d_x1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
d_y1floor = floor(d_y1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
i32_xsize = (int32_t)floor(d_x2 - d_subsize / 2.0) - (int32_t)d_x1floor + 1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_image = this->_dp_subpixel_image;
|
|
Shinya Kitaoka |
120a6e |
dp_save = this->_dp_pixel_image;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (d_y = d_y1 + d_subsize / 2.0; d_y < d_y2; d_y += d_subsize) {
|
|
Shinya Kitaoka |
120a6e |
for (d_x = d_x1 + d_subsize / 2.0; d_x < d_x2;
|
|
Shinya Kitaoka |
120a6e |
d_x += d_subsize, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
d_xsave = d_x - d_x1floor;
|
|
Shinya Kitaoka |
120a6e |
d_ysave = d_y - d_y1floor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int32_t)d_xsave);
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int32_t)d_ysave);
|
|
Shinya Kitaoka |
120a6e |
assert((int32_t)d_xsave < (this->_i32_size_by_pixel + 1));
|
|
Shinya Kitaoka |
120a6e |
assert((int32_t)d_ysave < (this->_i32_size_by_pixel + 1));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 5; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_save[(int32_t)d_ysave * i32_xsize * 5 + (int32_t)d_xsave * 5 + zz] +=
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_save = this->_dp_pixel_image;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < this->_i32_size_by_pixel + 1; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < this->_i32_size_by_pixel + 1; ++jj, dp_save += 5) {
|
|
Shinya Kitaoka |
120a6e |
for (zz = 0; zz < 5; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
dp_save[zz] /= this->_i32_subpixel_divide * this->_i32_subpixel_divide;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __calculator_geometry_h__
|
|
Toshihiro Shimizu |
890ddd |
#define __calculator_geometry_h__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class calculator_geometry {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
double get_d_radian(double d_xv, double d_yv);
|
|
Shinya Kitaoka |
120a6e |
double get_d_radian_by_2_vector(double d_xv1, double d_yv1, double d_xv2,
|
|
Shinya Kitaoka |
120a6e |
double d_yv2);
|
|
Shinya Kitaoka |
120a6e |
void get_dd_rotate(double d_xp1, double d_yp1, double d_radian,
|
|
Shinya Kitaoka |
120a6e |
double *dp_xp2, double *dp_yp2);
|
|
Shinya Kitaoka |
120a6e |
void get_dd_mirror(double d_xp1, double d_yp1, double d_mirror_xc,
|
|
Shinya Kitaoka |
120a6e |
double d_mirror_yc, double d_mirror_radian, double *dp_xp2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yp2);
|
|
Shinya Kitaoka |
120a6e |
void get_dd_rotate_by_pos(double d_xp1, double d_yp1, double d_xpos,
|
|
Shinya Kitaoka |
120a6e |
double d_ypos, double d_radian, double *dp_xp2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yp2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* sin(),cos(),atan(), M_PI */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "calculator_geometry.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#define M_PI 3.14159265358979323846
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ベクトルの角度を"0"から"2*PI"で返す */
|
|
Shinya Kitaoka |
120a6e |
double calculator_geometry::get_d_radian(double d_xv, double d_yv) {
|
|
Shinya Kitaoka |
120a6e |
double d_radian;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 == d_xv) && (0.0 == d_yv)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Warning : calculator_geometry::get_d_radian(d_xv,d_yv is zero).");
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((0.0 < d_xv) && (0.0 <= d_yv)) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = atan(d_yv / d_xv);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((d_xv <= 0.0) && (0.0 < d_yv)) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = atan(-d_xv / d_yv) + M_PI_2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((d_xv < 0.0) && (d_yv <= 0.0)) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = atan(d_yv / d_xv) + M_PI;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((0.0 <= d_xv) && (d_yv < 0.0)) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = atan(d_xv / -d_yv) + M_PI + M_PI_2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return d_radian;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double calculator_geometry::get_d_radian_by_2_vector(double d_xv1, double d_yv1,
|
|
Shinya Kitaoka |
120a6e |
double d_xv2,
|
|
Shinya Kitaoka |
120a6e |
double d_yv2) {
|
|
Shinya Kitaoka |
120a6e |
double d_radian_start, d_radian_end;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 == d_xv1) && (0.0 == d_yv1)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Warning : calculator_geometry::get_d_radian_by_2_vector(d_xv1,d_yv1 "
|
|
Shinya Kitaoka |
120a6e |
"is zero).");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 == d_xv2) && (0.0 == d_yv2)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Warning : calculator_geometry::get_d_radian_by_2_vector(d_xv2,d_yv2 "
|
|
Shinya Kitaoka |
120a6e |
"is zero).");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian_start = this->get_d_radian(d_xv1, d_yv1);
|
|
Shinya Kitaoka |
120a6e |
d_radian_end = this->get_d_radian(d_xv2, d_yv2);
|
|
Shinya Kitaoka |
120a6e |
if (d_radian_end < d_radian_start) {
|
|
Shinya Kitaoka |
120a6e |
d_radian_end += M_PI * 2.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return d_radian_end - d_radian_start;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void calculator_geometry::get_dd_rotate(double d_xp1, double d_yp1,
|
|
Shinya Kitaoka |
120a6e |
double d_radian, double *dp_xp2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yp2) {
|
|
Shinya Kitaoka |
120a6e |
*dp_xp2 = d_xp1 * cos(d_radian) - d_yp1 * sin(d_radian);
|
|
Shinya Kitaoka |
120a6e |
*dp_yp2 = d_xp1 * sin(d_radian) + d_yp1 * cos(d_radian);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void calculator_geometry::get_dd_mirror(double d_xp1, double d_yp1,
|
|
Shinya Kitaoka |
120a6e |
double d_mirror_xpos,
|
|
Shinya Kitaoka |
120a6e |
double d_mirror_ypos,
|
|
Shinya Kitaoka |
120a6e |
double d_mirror_radian, double *dp_xp2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yp2) {
|
|
Shinya Kitaoka |
120a6e |
d_xp1 -= d_mirror_xpos;
|
|
Shinya Kitaoka |
120a6e |
d_yp1 -= d_mirror_ypos;
|
|
Shinya Kitaoka |
120a6e |
this->get_dd_rotate(d_xp1, d_yp1, -d_mirror_radian, &d_xp1, &d_yp1);
|
|
Shinya Kitaoka |
120a6e |
this->get_dd_rotate(d_xp1, -d_yp1, d_mirror_radian, &d_xp1, &d_yp1);
|
|
Shinya Kitaoka |
120a6e |
*dp_xp2 = d_xp1 + d_mirror_xpos;
|
|
Shinya Kitaoka |
120a6e |
*dp_yp2 = d_yp1 + d_mirror_ypos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void calculator_geometry::get_dd_rotate_by_pos(double d_xp1, double d_yp1,
|
|
Shinya Kitaoka |
120a6e |
double d_xpos, double d_ypos,
|
|
Shinya Kitaoka |
120a6e |
double d_radian, double *dp_xp2,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yp2) {
|
|
Shinya Kitaoka |
120a6e |
d_xp1 -= d_xpos;
|
|
Shinya Kitaoka |
120a6e |
d_yp1 -= d_ypos;
|
|
Shinya Kitaoka |
120a6e |
this->get_dd_rotate(d_xp1, d_yp1, d_radian, &d_xp1, &d_yp1);
|
|
Shinya Kitaoka |
120a6e |
*dp_xp2 = d_xp1 + d_xpos;
|
|
Shinya Kitaoka |
120a6e |
*dp_yp2 = d_yp1 + d_ypos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pixel_point_node_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pixel_point_node_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
typedef int int32_t;
|
|
Toshihiro Shimizu |
890ddd |
typedef unsigned short uint16_t;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <stdint.h> /* for int32_t, uint16_t */</stdint.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef OK
|
|
Toshihiro Shimizu |
890ddd |
#define OK (0)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#ifndef NG
|
|
Toshihiro Shimizu |
890ddd |
#define NG (-1)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef LINK_NEAR_COUNT
|
|
Toshihiro Shimizu |
890ddd |
#define LINK_NEAR_COUNT 4
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_point_node final : public list_node {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node() {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xp = 0;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_yp = 0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_xp_tgt = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_yp_tgt = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link_near[ii] = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
this->_clp_previous_point = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clp_next_point = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_xp(int32_t i32) { this->_i32_xp = i32; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_yp(int32_t i32) { this->_i32_yp = i32; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_xp_tgt(double dd) { this->_d_xp_tgt = dd; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_yp_tgt(double dd) { this->_d_yp_tgt = dd; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_xp(void) { return this->_i32_xp; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_yp(void) { return this->_i32_yp; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_xp_tgt(void) { return this->_d_xp_tgt; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_yp_tgt(void) { return this->_d_yp_tgt; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int link_near(pixel_point_node *clp_);
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_near(int32_t i32);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_clp_next_point(pixel_point_node *clp) {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_next_point = clp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void set_clp_previous_point(pixel_point_node *clp) {
|
|
Shinya Kitaoka |
120a6e |
this->_clp_previous_point = clp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_next_point(void) { return this->_clp_next_point; }
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_previous_point(void) {
|
|
Shinya Kitaoka |
120a6e |
return this->_clp_previous_point;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void print_xy_around(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_xp, _i32_yp;
|
|
Shinya Kitaoka |
120a6e |
double _d_xp_tgt, _d_yp_tgt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_clpa_link_near[LINK_NEAR_COUNT];
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_clp_previous_point, *_clp_next_point;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_point_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_point_node::link_near(pixel_point_node *clp_) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL == this->_clpa_link_near[ii]) {
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link_near[ii] = clp_;
|
|
Shinya Kitaoka |
120a6e |
return ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : no link_near point, over %d.",
|
|
Shinya Kitaoka |
120a6e |
LINK_NEAR_COUNT - 1);
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("this x %d y %d", this->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
this->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != this->_clpa_link_near[ii]);
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("link_near %d x %d y %d", ii,
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link_near[ii]->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link_near[ii]->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *pixel_point_node::get_clp_link_near(int32_t i32) {
|
|
Shinya Kitaoka |
120a6e |
if (LINK_NEAR_COUNT <= i32) return NULL;
|
|
Shinya Kitaoka |
120a6e |
return this->_clpa_link_near[i32];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_point_node::print_xy_around(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(
|
|
Shinya Kitaoka |
120a6e |
"pixel_point_node::debug_print_xy_around() : self address <0x%lx>", this);
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" self x %d y %d", this->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
this->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->get_clp_link_near(ii)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" link_near %d x %d y %d", ii,
|
|
Shinya Kitaoka |
120a6e |
this->get_clp_link_near(ii)->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
this->get_clp_link_near(ii)->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" link_near %ld is not exist(NULL).", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pixel_point_root_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pixel_point_root_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_root.h" "pixel_point_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_point_root final : public list_root {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root(void) {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~pixel_point_root(void) { this->mem_free(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool sw) { this->_i_mv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool sw) { this->_i_cv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool sw) { this->_i_pv_sw = sw; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int alloc_mem_and_list_node(int32_t i32_xs, int32_t i32_ys,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *append(pixel_point_node *clp_previous);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* for debug */
|
|
Shinya Kitaoka |
120a6e |
int save(const char *cp_fname);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw, _i_cv_sw, _i_pv_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void _remove(pixel_point_node *clp_target);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_point_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *pixel_point_root::append(pixel_point_node *clp_previous) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_new;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_new = new pixel_point_node;
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_new) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : 'new pixel_point_node' returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_new = (pixel_point_node *)this->push(clp_previous, clp_new);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return clp_new;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_point_root::_remove(pixel_point_node *clp_old) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_old);
|
|
Shinya Kitaoka |
120a6e |
this->pop(clp_old);
|
|
Shinya Kitaoka |
120a6e |
delete clp_old;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_point_root::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->get_clp_last()) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_point_root::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
while (NULL != (clp_ = (pixel_point_node *)this->get_clp_last())) {
|
|
Shinya Kitaoka |
120a6e |
this->_remove(clp_);
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("free point node %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_point_root::alloc_mem_and_list_node(int32_t i32_xs, int32_t i32_ys,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src) {
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_pp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_point_root::alloc_mem_and_list_node()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(i32_ys);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_pp = NULL;
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < i32_xs; ++xx, ++ui16p_src) {
|
|
Shinya Kitaoka |
120a6e |
if (0 < (*ui16p_src)) {
|
|
Shinya Kitaoka |
120a6e |
clp_pp = this->append(clp_pp);
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_pp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->append(clp_pp) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_pp->set_i32_xp(xx);
|
|
Shinya Kitaoka |
120a6e |
clp_pp->set_i32_yp(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("alloc and list %d points", this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_point_root::save(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_pp_node;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != cp_fname);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s) returns NULL.", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(count) returns minus.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_pp_node = (pixel_point_node *)this->get_clp_first(), ii = 0L;
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_pp_node) && (ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
clp_pp_node = (pixel_point_node *)clp_pp_node->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_pp_node->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_pp_node->get_i32_yp()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(count xp yp) returns minus.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#ifndef _pixel_line_node_h_
|
|
Shinya Kitaoka |
120a6e |
#define _pixel_line_node_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "calculator_geometry.h" "list_node.h" "pixel_point_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#ifndef OK
|
|
Shinya Kitaoka |
120a6e |
#define OK (0)
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Shinya Kitaoka |
120a6e |
#ifndef NG
|
|
Shinya Kitaoka |
120a6e |
#define NG (-1)
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_line_node final : public list_node {
|
|
Shinya Kitaoka |
120a6e |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node() {
|
|
Shinya Kitaoka |
120a6e |
this->_i32_point_count = 0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_same_way_radian_one = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_same_way_radian_another = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link[0] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link[1] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link[2] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link[3] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_clpa_link[4] = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_point_count(void) { return this->_i32_point_count; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_same_way_radian_one(double dd) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_same_way_radian_one = dd;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void set_d_same_way_radian_another(double dd) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_same_way_radian_another = dd;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
double get_d_same_way_radian_one(void) {
|
|
Shinya Kitaoka |
120a6e |
return this->_d_same_way_radian_one;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
double get_d_same_way_radian_another(void) {
|
|
Shinya Kitaoka |
120a6e |
return this->_d_same_way_radian_another;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_x_min(void) { return this->_d_bbox_x_min; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_x_max(void) { return this->_d_bbox_x_max; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_y_min(void) { return this->_d_bbox_y_min; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_y_max(void) { return this->_d_bbox_y_max; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void link_one(pixel_point_node *clp) { this->_clpa_link[0] = clp; }
|
|
Shinya Kitaoka |
120a6e |
void link_another(pixel_point_node *clp) { this->_clpa_link[1] = clp; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void link_middle(pixel_point_node *clp) { this->_clpa_link[2] = clp; }
|
|
Shinya Kitaoka |
120a6e |
void link_one_expand(pixel_point_node *clp) { this->_clpa_link[3] = clp; }
|
|
Shinya Kitaoka |
120a6e |
void link_another_expand(pixel_point_node *clp) { this->_clpa_link[4] = clp; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_one(void) { return this->_clpa_link[0]; }
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_another(void) { return this->_clpa_link[1]; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_middle(void) { return this->_clpa_link[2]; }
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_one_expand(void) {
|
|
Shinya Kitaoka |
120a6e |
return this->_clpa_link[3];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_clp_link_another_expand(void) {
|
|
Shinya Kitaoka |
120a6e |
return this->_clpa_link[4];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_middle(void);
|
|
Shinya Kitaoka |
120a6e |
void int2double_body(void);
|
|
Shinya Kitaoka |
120a6e |
void smooth_body(int32_t i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
void smooth_expand(int32_t i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
void link_line(pixel_point_node *clp_crnt, pixel_point_node *clp_next,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
void get_near_point(double d_xp, double d_yp, int32_t *i32p_pos,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node **clpp_point, double *dp_length);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_next_point_by_count(pixel_point_node *clp_point,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *get_prev_point_by_count(pixel_point_node *clp_point,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
void set_bbox(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save_line(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_one_point(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_middle_point(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_another_point(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int expand_line(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save_expand_line(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_expand_vector(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_one_expand_point(FILE *fp);
|
|
Shinya Kitaoka |
120a6e |
int save_another_expand_point(FILE *fp);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
private:
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_point_count;
|
|
Shinya Kitaoka |
120a6e |
double _d_same_way_radian_one, _d_same_way_radian_another;
|
|
Shinya Kitaoka |
120a6e |
double _d_bbox_x_min, _d_bbox_x_max, _d_bbox_y_min, _d_bbox_y_max;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_clpa_link[5];
|
|
Shinya Kitaoka |
120a6e |
calculator_geometry _cl_cal_geom;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int _expand_line_from_one(pixel_point_root *clp_pp_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_another, double d_radian);
|
|
Shinya Kitaoka |
120a6e |
int _expand_line_from_another(pixel_point_root *clp_pp_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_another, double d_radian);
|
|
Shinya Kitaoka |
120a6e |
void _smooth_point(double d_x1, double d_y1, double d_x2, double d_y2,
|
|
Shinya Kitaoka |
120a6e |
double d_x3, double d_y3, double *dp_x, double *dp_y);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void _get_link_line_selecter_vector(pixel_point_node *clp_crnt,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_next, double *dp_xv,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yv, int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_get_link_line_selecter(double d_xv, double d_yv,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h></assert.h>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_node.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::_expand_line_from_one(pixel_point_root *clp_pp_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_another,
|
|
Shinya Kitaoka |
120a6e |
double d_radian) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_last, *clp_before, *clp_exist;
|
|
Shinya Kitaoka |
120a6e |
double d_xp, d_yp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before = clp_one;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ライン開始点(clp_one)から後ろへたどる、
|
|
Shinya Kitaoka |
120a6e |
始まりは開始点でなくその一つ後ろから */
|
|
Shinya Kitaoka |
120a6e |
for (ii = 1, clp_exist = clp_one->get_clp_next_point(); NULL != clp_exist;
|
|
Shinya Kitaoka |
120a6e |
++ii, clp_exist = clp_exist->get_clp_next_point()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < i32_body_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_last =
|
|
Shinya Kitaoka |
120a6e |
clp_pp_root->append((pixel_point_node *)(clp_pp_root->get_clp_last()));
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_last) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : ii %d : this->append(clp_last) returns NULL.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before->set_clp_previous_point(clp_last);
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_clp_next_point(clp_before);
|
|
Shinya Kitaoka |
120a6e |
this->link_one_expand(clp_last);
|
|
Shinya Kitaoka |
120a6e |
++this->_i32_point_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_cl_cal_geom.get_dd_mirror(
|
|
Shinya Kitaoka |
120a6e |
clp_exist->get_d_xp_tgt(), clp_exist->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_one->get_d_xp_tgt(), clp_one->get_d_yp_tgt(), d_radian, &d_xp,
|
|
Shinya Kitaoka |
120a6e |
&d_yp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_d_xp_tgt(d_xp);
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_d_yp_tgt(d_yp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before = clp_last;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_another == clp_exist) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::_expand_line_from_another(pixel_point_root *clp_pp_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_another,
|
|
Shinya Kitaoka |
120a6e |
double d_radian) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_last, *clp_before, *clp_exist;
|
|
Shinya Kitaoka |
120a6e |
double d_xp, d_yp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before = clp_another;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ライン最終点(clp_another)から前へたどる、
|
|
Shinya Kitaoka |
120a6e |
始まりは最終点でなくその一つ前から */
|
|
Shinya Kitaoka |
120a6e |
for (ii = 1, clp_exist = clp_another->get_clp_previous_point();
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_exist;
|
|
Shinya Kitaoka |
120a6e |
++ii, clp_exist = clp_exist->get_clp_previous_point()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < i32_body_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_last =
|
|
Shinya Kitaoka |
120a6e |
clp_pp_root->append((pixel_point_node *)(clp_pp_root->get_clp_last()));
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_last) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : ii %d : this->append(clp_last) returns NULL.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before->set_clp_next_point(clp_last);
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_clp_previous_point(clp_before);
|
|
Shinya Kitaoka |
120a6e |
this->link_another_expand(clp_last);
|
|
Shinya Kitaoka |
120a6e |
++this->_i32_point_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_cl_cal_geom.get_dd_mirror(
|
|
Shinya Kitaoka |
120a6e |
clp_exist->get_d_xp_tgt(), clp_exist->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_another->get_d_xp_tgt(), clp_another->get_d_yp_tgt(), d_radian,
|
|
Shinya Kitaoka |
120a6e |
&d_xp, &d_yp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_d_xp_tgt(d_xp);
|
|
Shinya Kitaoka |
120a6e |
clp_last->set_d_yp_tgt(d_yp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_before = clp_last;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_one == clp_exist) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::expand_line(pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one, *clp_middle, *clp_another;
|
|
Shinya Kitaoka |
120a6e |
double d_radian, d_radian_one, d_radian_another;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_body_point_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_i32_point_count < 3) {
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_one = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
clp_another = this->get_clp_link_another();
|
|
Shinya Kitaoka |
120a6e |
clp_middle = this->get_clp_link_middle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_one != clp_another);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_another != clp_middle);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_middle != clp_one);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert((clp_one->get_i32_xp() != clp_middle->get_i32_xp()) ||
|
|
Shinya Kitaoka |
120a6e |
(clp_one->get_i32_yp() != clp_middle->get_i32_yp()));
|
|
Shinya Kitaoka |
120a6e |
assert((clp_another->get_i32_xp() != clp_middle->get_i32_xp()) ||
|
|
Shinya Kitaoka |
120a6e |
(clp_another->get_i32_yp() != clp_middle->get_i32_yp()));
|
|
Shinya Kitaoka |
120a6e |
d_radian = this->_cl_cal_geom.get_d_radian_by_2_vector(
|
|
Shinya Kitaoka |
120a6e |
clp_one->get_i32_xp() - clp_middle->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_one->get_i32_yp() - clp_middle->get_i32_yp(),
|
|
Shinya Kitaoka |
120a6e |
clp_another->get_i32_xp() - clp_middle->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_another->get_i32_yp() - clp_middle->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian /= 2.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian_one = this->_cl_cal_geom.get_d_radian(
|
|
Shinya Kitaoka |
120a6e |
clp_middle->get_i32_xp() - clp_one->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_middle->get_i32_yp() - clp_one->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian_one -= d_radian;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian_another = this->_cl_cal_geom.get_d_radian(
|
|
Shinya Kitaoka |
120a6e |
clp_middle->get_i32_xp() - clp_another->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_middle->get_i32_yp() - clp_another->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian_another += d_radian;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_body_point_count = this->_i32_point_count;
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_one->get_clp_link_near(1)) {
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
this->_expand_line_from_one(clp_pixel_point_root, i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
this->get_clp_link_one(),
|
|
Shinya Kitaoka |
120a6e |
this->get_clp_link_another(),
|
|
Shinya Kitaoka |
120a6e |
d_radian_one)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : this->_expand_line_from_one(-) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_another->get_clp_link_near(1)) {
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
this->_expand_line_from_another(
|
|
Shinya Kitaoka |
120a6e |
clp_pixel_point_root, i32_body_point_count,
|
|
Shinya Kitaoka |
120a6e |
this->get_clp_link_one(), this->get_clp_link_another(),
|
|
Shinya Kitaoka |
120a6e |
d_radian_another)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : this->_expand_line_from_another(-) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <math.h> /* sqrt() */</math.h>
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::get_near_point(double d_xp, double d_yp,
|
|
Shinya Kitaoka |
120a6e |
int32_t *i32p_pos,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node **clpp_point,
|
|
Shinya Kitaoka |
120a6e |
double *dp_length) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_loop;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
double d_length;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != this->get_clp_link_one_expand());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*dp_length = 1000.0;
|
|
Shinya Kitaoka |
120a6e |
clp_loop = this->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_loop;
|
|
Shinya Kitaoka |
120a6e |
++ii, clp_loop = clp_loop->get_clp_next_point()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_length = sqrt(
|
|
Shinya Kitaoka |
120a6e |
(clp_loop->get_d_xp_tgt() - d_xp) * (clp_loop->get_d_xp_tgt() - d_xp) +
|
|
Shinya Kitaoka |
120a6e |
(clp_loop->get_d_yp_tgt() - d_yp) * (clp_loop->get_d_yp_tgt() - d_yp));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (d_length < (*dp_length)) {
|
|
Shinya Kitaoka |
120a6e |
*i32p_pos = ii;
|
|
Shinya Kitaoka |
120a6e |
*clpp_point = clp_loop;
|
|
Shinya Kitaoka |
120a6e |
*dp_length = d_length;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::int2double_body(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_1;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_1 = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_1; clp_1 = clp_1->get_clp_next_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_1->set_d_xp_tgt((double)clp_1->get_i32_xp());
|
|
Shinya Kitaoka |
120a6e |
clp_1->set_d_yp_tgt((double)clp_1->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <math.h> /* M_PI */</math.h>
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Shinya Kitaoka |
120a6e |
#define M_PI 3.14159265358979323846
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::_get_link_line_selecter_vector(pixel_point_node *clp_crnt,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_next,
|
|
Shinya Kitaoka |
120a6e |
double *dp_xv,
|
|
Shinya Kitaoka |
120a6e |
double *dp_yv,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_start;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_start = clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; (NULL != clp_next) && (ii < i32_count); ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_next->get_clp_next_point()) ||
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_next->get_clp_previous_point())) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL == clp_next->get_clp_link_near(1))) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_next->get_clp_link_near(2)) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_crnt == clp_next->get_clp_link_near(0)) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next = clp_next->get_clp_link_near(1);
|
|
Shinya Kitaoka |
120a6e |
} else if (clp_crnt == clp_next->get_clp_link_near(1)) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next = clp_next->get_clp_link_near(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : bad link");
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*dp_xv = clp_crnt->get_i32_xp() - clp_start->get_i32_xp();
|
|
Shinya Kitaoka |
120a6e |
*dp_yv = clp_crnt->get_i32_yp() - clp_start->get_i32_yp();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *pixel_line_node::_get_link_line_selecter(
|
|
Shinya Kitaoka |
120a6e |
double d_xv, double d_yv, pixel_point_node *clp_crnt, int32_t i32_count) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, i32_pos;
|
|
Shinya Kitaoka |
120a6e |
double da_xv[LINK_NEAR_COUNT], da_yv[LINK_NEAR_COUNT],
|
|
Shinya Kitaoka |
120a6e |
da_radian[LINK_NEAR_COUNT], d_radian;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert((0.0 != d_xv) || (0.0 != d_yv));
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_crnt->get_clp_link_near(ii)) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
this->_get_link_line_selecter_vector(clp_crnt,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_clp_link_near(ii),
|
|
Shinya Kitaoka |
120a6e |
&da_xv[ii], &da_yv[ii], i32_count);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_crnt->get_clp_link_near(ii)) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 != da_xv[ii]) || (0.0 != da_yv[ii])) {
|
|
Shinya Kitaoka |
120a6e |
da_radian[ii] = this->_cl_cal_geom.get_d_radian_by_2_vector(
|
|
Shinya Kitaoka |
120a6e |
d_xv, d_yv, da_xv[ii], da_yv[ii]);
|
|
Shinya Kitaoka |
120a6e |
if (M_PI < da_radian[ii]) {
|
|
Shinya Kitaoka |
120a6e |
da_radian[ii] = M_PI - (da_radian[ii] - M_PI);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
da_radian[ii] = M_PI;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radian = M_PI * 2.0;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < LINK_NEAR_COUNT; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_crnt->get_clp_link_near(ii)) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (da_radian[ii] < d_radian) {
|
|
Shinya Kitaoka |
120a6e |
i32_pos = ii;
|
|
Shinya Kitaoka |
120a6e |
d_radian = da_radian[ii];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/* もっとも直線と見なされる(角度の小さい)といっても
|
|
Shinya Kitaoka |
120a6e |
90度以上も曲がってたらだめ */
|
|
Shinya Kitaoka |
120a6e |
if ((M_PI / 2.0 <= d_radian) && (d_radian <= M_PI * 3.0 / 2.0)) return NULL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return clp_crnt->get_clp_link_near(i32_pos);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::link_line(pixel_point_node *clp_crnt,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_next, int32_t i32_count) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_tmp1, *clp_tmp2;
|
|
Shinya Kitaoka |
120a6e |
double d_xv, d_yv;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_next);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->link_one(clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++(this->_i32_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_tmp1 = clp_tmp2 = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
d_xv = d_yv = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; (NULL != clp_next) && (ii < i32_count); ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_next->get_clp_next_point()) ||
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_next->get_clp_previous_point())) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->link_another(clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->set_clp_next_point(clp_next);
|
|
Shinya Kitaoka |
120a6e |
clp_next->set_clp_previous_point(clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
++(this->_i32_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL == clp_next->get_clp_link_near(1))) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->link_another(clp_next);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_next->get_clp_link_near(2)) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_tmp2 = clp_tmp1;
|
|
Shinya Kitaoka |
120a6e |
clp_tmp1 = clp_next;
|
|
Shinya Kitaoka |
120a6e |
assert(clp_tmp1 != clp_tmp2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_xv = clp_tmp1->get_i32_xp() - clp_tmp2->get_i32_xp();
|
|
Shinya Kitaoka |
120a6e |
d_yv = clp_tmp1->get_i32_yp() - clp_tmp2->get_i32_yp();
|
|
Shinya Kitaoka |
120a6e |
assert((0.0 != d_xv) || (0.0 != d_yv));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next = this->_get_link_line_selecter(d_xv, d_yv, clp_next, i32_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* たどる線がすでにたどっているものの場合、
|
|
Shinya Kitaoka |
120a6e |
そこで、終端 */
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_next) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->link_another(clp_crnt);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_crnt == clp_next->get_clp_link_near(0)) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next = clp_next->get_clp_link_near(1);
|
|
Shinya Kitaoka |
120a6e |
} else if (clp_crnt == clp_next->get_clp_link_near(1)) {
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_next;
|
|
Shinya Kitaoka |
120a6e |
clp_next = clp_next->get_clp_link_near(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : bad link");
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : too long link");
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur.cxx
|
|
Shinya Kitaoka |
120a6e |
の、
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_curve_blur_root::exec( double d_xp, double d_yp,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line_first, int32_t i32_count, int32_t i32_blur_count )
|
|
Shinya Kitaoka |
120a6e |
で使用。
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *pixel_line_node::get_next_point_by_count(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point, int32_t i32_count) {
|
|
Shinya Kitaoka |
120a6e |
for (; (0 < i32_count) && (NULL != clp_point);
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
return clp_point;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *pixel_line_node::get_prev_point_by_count(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point, int32_t i32_count) {
|
|
Shinya Kitaoka |
120a6e |
for (; (0 < i32_count) && (NULL != clp_point);
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_previous_point();
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
return clp_point;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_line(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_crnt->get_clp_next_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp()) <
|
|
Shinya Kitaoka |
120a6e |
0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : point %d : fprintf(%d %d) returns minus", ii,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_one_point(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_one();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_crnt) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp()) <
|
|
Shinya Kitaoka |
120a6e |
0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : one point : fprintf(%d %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_middle_point(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_middle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_crnt) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp()) <
|
|
Shinya Kitaoka |
120a6e |
0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : middle point : fprintf(%d %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_another_point(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_another();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_crnt) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp()) <
|
|
Shinya Kitaoka |
120a6e |
0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : another point : fprintf(%d %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_i32_xp(), clp_crnt->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_expand_line(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_crnt->get_clp_next_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : point %d : fprintf(%g %g) returns minus", ii,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_one_expand_point(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_one_expand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_crnt) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : one expand point : fprintf(%g %g) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_another_expand_point(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_crnt;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = this->get_clp_link_another_expand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_crnt) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : another expand point : fprintf(%g %g) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_node::save_expand_vector(FILE *fp) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_term, *clp_expa;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_term = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
clp_expa = this->get_clp_link_one_expand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_term) && (NULL != clp_expa)) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(fp, "%g %g %g %g\n", clp_term->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_term->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_expa->get_d_xp_tgt() - clp_term->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_expa->get_d_yp_tgt() - clp_term->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
if (ferror(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(one and one_expand xp and yp)");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_term = this->get_clp_link_another();
|
|
Shinya Kitaoka |
120a6e |
clp_expa = this->get_clp_link_another_expand();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_term) && (NULL != clp_expa)) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(fp, "%g %g %g %g\n", clp_term->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_term->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_expa->get_d_xp_tgt() - clp_term->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_expa->get_d_yp_tgt() - clp_term->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
if (ferror(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : fprintf(another and another_expand xp and yp)");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::set_bbox(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_point = this->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_point) {
|
|
Shinya Kitaoka |
120a6e |
clp_point = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_point->get_clp_next_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (0 == ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = clp_point->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = clp_point->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = clp_point->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = clp_point->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (clp_point->get_d_xp_tgt() < this->_d_bbox_x_min) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = clp_point->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
} else if (this->_d_bbox_x_max < clp_point->get_d_xp_tgt()) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = clp_point->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (clp_point->get_d_yp_tgt() < this->_d_bbox_y_min) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = clp_point->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
} else if (this->_d_bbox_y_max < clp_point->get_d_yp_tgt()) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = clp_point->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::set_middle(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_middle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != this->get_clp_link_one());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0, clp_middle = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
(ii < (this->_i32_point_count) / 2) && (NULL != clp_middle); ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_middle->get_clp_next_point()) {
|
|
Shinya Kitaoka |
120a6e |
clp_middle = clp_middle->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_middle != this->get_clp_link_one());
|
|
Shinya Kitaoka |
120a6e |
assert(clp_middle != this->get_clp_link_another());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->link_middle(clp_middle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pixel_line_node.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 3点から線分がスムースになるような中点を計算する
|
|
Shinya Kitaoka |
120a6e |
* p1
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
| +
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
| * <-- new p2
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
*
|
|
Shinya Kitaoka |
120a6e |
p2 |p3
|
|
Shinya Kitaoka |
120a6e |
* |
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
+ | +
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
| *
|
|
Shinya Kitaoka |
120a6e |
|
|
|
Shinya Kitaoka |
120a6e |
*
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::_smooth_point(double d_x1, double d_y1, double d_x2,
|
|
Shinya Kitaoka |
120a6e |
double d_y2, double d_x3, double d_y3,
|
|
Shinya Kitaoka |
120a6e |
double *dp_x, double *dp_y) {
|
|
Shinya Kitaoka |
120a6e |
*dp_x = (d_x2 + ((d_x1 + d_x3) / 2.0)) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
*dp_y = (d_y2 + ((d_y1 + d_y3) / 2.0)) / 2.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::smooth_body(int32_t i32_smooth_retry) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_1, *clp_2, *clp_3;
|
|
Shinya Kitaoka |
120a6e |
int32_t kk, ii;
|
|
Shinya Kitaoka |
120a6e |
double d_x, d_y, d_x1, d_y1, d_x2 = 0, d_y2 = 0, d_x3, d_y3;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (kk = 0; kk < i32_smooth_retry; ++kk) {
|
|
Shinya Kitaoka |
120a6e |
clp_1 = this->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
clp_2 = clp_3 = NULL;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_1; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->_i32_point_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_x1 = clp_1->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
d_y1 = clp_1->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_3) {
|
|
Shinya Kitaoka |
120a6e |
this->_smooth_point(d_x1, d_y1, d_x2, d_y2, d_x3, d_y3, &d_x, &d_y);
|
|
Shinya Kitaoka |
120a6e |
clp_2->set_d_xp_tgt(d_x);
|
|
Shinya Kitaoka |
120a6e |
clp_2->set_d_yp_tgt(d_y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->get_clp_link_another() == clp_1) break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_3 = clp_2;
|
|
Shinya Kitaoka |
120a6e |
d_x3 = d_x2;
|
|
Shinya Kitaoka |
120a6e |
d_y3 = d_y2;
|
|
Shinya Kitaoka |
120a6e |
clp_2 = clp_1;
|
|
Shinya Kitaoka |
120a6e |
d_x2 = d_x1;
|
|
Shinya Kitaoka |
120a6e |
d_y2 = d_y1;
|
|
Shinya Kitaoka |
120a6e |
clp_1 = clp_1->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_node::smooth_expand(int32_t i32_smooth_retry) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_1, *clp_2, *clp_3;
|
|
Shinya Kitaoka |
120a6e |
int32_t kk, ii;
|
|
Shinya Kitaoka |
120a6e |
double d_x, d_y, d_x1, d_y1, d_x2, d_y2, d_x3, d_y3;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (kk = 0; kk < i32_smooth_retry; ++kk) {
|
|
Shinya Kitaoka |
120a6e |
clp_1 = this->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
clp_2 = clp_3 = NULL;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_1; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < (this->_i32_point_count));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_x1 = clp_1->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
d_y1 = clp_1->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_3) {
|
|
Shinya Kitaoka |
120a6e |
this->_smooth_point(d_x1, d_y1, d_x2, d_y2, d_x3, d_y3, &d_x, &d_y);
|
|
Shinya Kitaoka |
120a6e |
clp_2->set_d_xp_tgt(d_x);
|
|
Shinya Kitaoka |
120a6e |
clp_2->set_d_yp_tgt(d_y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->get_clp_link_another_expand() == clp_1) break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_3 = clp_2;
|
|
Shinya Kitaoka |
120a6e |
d_x3 = d_x2;
|
|
Shinya Kitaoka |
120a6e |
d_y3 = d_y2;
|
|
Shinya Kitaoka |
120a6e |
clp_2 = clp_1;
|
|
Shinya Kitaoka |
120a6e |
d_x2 = d_x1;
|
|
Shinya Kitaoka |
120a6e |
d_y2 = d_y1;
|
|
Shinya Kitaoka |
120a6e |
clp_1 = clp_1->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pixel_select_same_way_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pixel_select_same_way_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_root.h" "calculator_geometry.h" "pixel_point_root.h" "pixel_line_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_select_same_way_node final : public list_node {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node(void) {
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_middle = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_term = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_expand = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->d_length = -1.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void copy(pixel_select_same_way_node *clp) {
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_middle = clp->clp_point_middle;
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_term = clp->clp_point_term;
|
|
Shinya Kitaoka |
120a6e |
this->clp_point_expand = clp->clp_point_expand;
|
|
Shinya Kitaoka |
120a6e |
this->d_length = clp->d_length;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_middle;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_expand;
|
|
Shinya Kitaoka |
120a6e |
double d_length;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_select_same_way_root final : public list_root {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_root(void) {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count_max = 4;
|
|
Shinya Kitaoka |
120a6e |
this->_d_length_max = 160;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~pixel_select_same_way_root(void) { this->mem_free(); }
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool sw) { this->_i_mv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool sw) { this->_i_cv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool sw) { this->_i_pv_sw = sw; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_count_max(void) { return this->_i32_count_max; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_count_max(int32_t ii) { this->_i32_count_max = ii; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_length_max(void) { return this->_d_length_max; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_length_max(double dd) { this->_d_length_max = dd; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void exec(pixel_line_node *clp_line_first, int32_t i32_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_middle,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_expand);
|
|
Shinya Kitaoka |
120a6e |
void get_vector(double *dp_xv, double *dp_yv);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw, _i_cv_sw, _i_pv_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_count_max;
|
|
Shinya Kitaoka |
120a6e |
double _d_length_max;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
calculator_geometry _cl_cal_geom;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *_append(pixel_select_same_way_node *clp_previous);
|
|
Shinya Kitaoka |
120a6e |
void _remove(pixel_select_same_way_node *clp_old);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int _sort_append(pixel_select_same_way_node *clp_src);
|
|
Shinya Kitaoka |
120a6e |
double _term_length(pixel_point_node *clp_middle1,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_term1,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_middle2,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_term2);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* sqrt() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h> /* free(), calloc() */</stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h" "pixel_select_same_way.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#define M_PI 3.14159265358979323846
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *pixel_select_same_way_root::_append(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_previous) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_new;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_new = new pixel_select_same_way_node;
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_new) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : 'new pixel_select_same_way_node' returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_new = (pixel_select_same_way_node *)this->push(clp_previous, clp_new);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return clp_new;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_same_way_root::_remove(pixel_select_same_way_node *clp_old) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_old);
|
|
Shinya Kitaoka |
120a6e |
this->pop(clp_old);
|
|
Shinya Kitaoka |
120a6e |
delete clp_old;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_same_way_root::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->get_clp_last()) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_select_same_way_root::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
while (NULL !=
|
|
Shinya Kitaoka |
120a6e |
(clp_ = (pixel_select_same_way_node *)this->get_clp_last())) {
|
|
Shinya Kitaoka |
120a6e |
this->_remove(clp_);
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("free select same way node %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* lengthの値を見て、小さい値順になるように追加する
|
|
Shinya Kitaoka |
120a6e |
他の選択より小さいなら先頭
|
|
Shinya Kitaoka |
120a6e |
他の選択より大きいなら最後に追加
|
|
Shinya Kitaoka |
120a6e |
他の選択の値の間入るならそこに追加
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
int pixel_select_same_way_root::_sort_append(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_src) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_loop, *clp_prev;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(0.0 < clp_src->d_length);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_same_way_node *)this->get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_loop) {
|
|
Shinya Kitaoka |
120a6e |
clp_prev = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if (NULL == clp_loop->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_src->d_length < clp_loop->d_length) {
|
|
Shinya Kitaoka |
120a6e |
clp_prev = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
clp_prev = clp_loop;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev = (pixel_select_same_way_node *)this->get_clp_last();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_loop; ++ii,
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_same_way_node *)clp_loop->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_src->d_length < clp_loop->d_length) {
|
|
Shinya Kitaoka |
120a6e |
clp_prev = (pixel_select_same_way_node *)clp_loop->get_clp_previous();
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev = this->_append(clp_prev);
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_prev) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_append(clp_prev) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev->copy(clp_src);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double pixel_select_same_way_root::_term_length(pixel_point_node *clp_middle1,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_term1,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_middle2,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_term2) {
|
|
Shinya Kitaoka |
120a6e |
double d_length, d_radian;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_term2 != clp_term1);
|
|
Shinya Kitaoka |
120a6e |
d_length = sqrt((clp_term2->get_d_xp_tgt() - clp_term1->get_d_xp_tgt()) *
|
|
Shinya Kitaoka |
120a6e |
(clp_term2->get_d_xp_tgt() - clp_term1->get_d_xp_tgt()) +
|
|
Shinya Kitaoka |
120a6e |
(clp_term2->get_d_yp_tgt() - clp_term1->get_d_yp_tgt()) *
|
|
Shinya Kitaoka |
120a6e |
(clp_term2->get_d_yp_tgt() - clp_term1->get_d_yp_tgt()));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 同方向のものでなければならない
|
|
Shinya Kitaoka |
120a6e |
2つの線分の角度をしらべ...
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
assert(clp_term1 != clp_middle1);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_term2 != clp_middle2);
|
|
Shinya Kitaoka |
120a6e |
d_radian = this->_cl_cal_geom.get_d_radian_by_2_vector(
|
|
Shinya Kitaoka |
120a6e |
clp_term1->get_d_xp_tgt() - clp_middle1->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_term1->get_d_yp_tgt() - clp_middle1->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_term2->get_d_xp_tgt() - clp_middle2->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_term2->get_d_yp_tgt() - clp_middle2->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((M_PI / 2.0 <= d_radian) && (d_radian <= M_PI * 3.0 / 2.0)) return -1.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_d_length_max <= d_length) return -1.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return d_length;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_same_way_root::exec(pixel_line_node *clp_line_first,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_middle,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_expand) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
double d_length;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node cl_select;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_middle != clp_point_term);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_term != clp_point_expand);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_expand != clp_point_middle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = clp_line_first, ii = 0; NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < i32_count);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 端点1が自分以外のときで、
|
|
Shinya Kitaoka |
120a6e |
線分が短すぎて(1点以下)真中指定と端点1が同じではない */
|
|
Shinya Kitaoka |
120a6e |
if ((clp_line->get_clp_link_one() != clp_point_term) &&
|
|
Shinya Kitaoka |
120a6e |
(clp_line->get_clp_link_middle() != clp_line->get_clp_link_one())) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_middle());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_one());
|
|
Shinya Kitaoka |
120a6e |
d_length = this->_term_length(clp_point_middle, clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_middle(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_one());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 < d_length) && (NULL != clp_line->get_clp_link_one_expand())) {
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_middle = clp_line->get_clp_link_middle();
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_term = clp_line->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_expand = clp_line->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
cl_select.d_length = d_length;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_sort_append(&cl_select);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 端点2が自分以外のときで、
|
|
Shinya Kitaoka |
120a6e |
線分が短すぎて(2点以下)真中指定と端点2が同じではない */
|
|
Shinya Kitaoka |
120a6e |
if ((clp_line->get_clp_link_another() != clp_point_term) &&
|
|
Shinya Kitaoka |
120a6e |
(clp_line->get_clp_link_middle() != clp_line->get_clp_link_another())) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_middle());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_another());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_length = this->_term_length(clp_point_middle, clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_middle(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_another());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 < d_length) &&
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_line->get_clp_link_another_expand())) {
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_middle = clp_line->get_clp_link_middle();
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_term = clp_line->get_clp_link_another();
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_point_expand = clp_line->get_clp_link_another_expand();
|
|
Shinya Kitaoka |
120a6e |
cl_select.d_length = d_length;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_sort_append(&cl_select);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 距離の近い順(lengthの小さい値)に指定個数分のベクトルを合成して返す
|
|
Shinya Kitaoka |
120a6e |
先頭から
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count_max数個分
|
|
Shinya Kitaoka |
120a6e |
のベクトルを合成する
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_same_way_root::get_vector(double *dp_xv, double *dp_yv) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_node *clp_loop;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_same_way_node *)this->get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; (NULL != clp_loop) && (ii < this->_i32_count_max); ++ii,
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_same_way_node *)clp_loop->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop->clp_point_expand);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop->clp_point_term);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*dp_xv += clp_loop->clp_point_expand->get_d_xp_tgt() -
|
|
Shinya Kitaoka |
120a6e |
clp_loop->clp_point_term->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
*dp_yv += clp_loop->clp_point_expand->get_d_yp_tgt() -
|
|
Shinya Kitaoka |
120a6e |
clp_loop->clp_point_term->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pixel_line_root_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pixel_line_root_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_root.h" "calculator_geometry.h" "pixel_point_root.h" "pixel_line_node.h" "pixel_select_same_way.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_line_root final : public list_root {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root(void) {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = 0.0;
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_smooth_retry = 100;
|
|
otakuto |
c39a2a |
this->_i_same_way_exec_sw = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~pixel_line_root(void) { this->mem_free(); }
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool sw) { this->_i_mv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool sw) { this->_i_cv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool sw) { this->_i_pv_sw = sw; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_x_min(void) { return this->_d_bbox_x_min; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_x_max(void) { return this->_d_bbox_x_max; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_y_min(void) { return this->_d_bbox_y_min; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_bbox_y_max(void) { return this->_d_bbox_y_max; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_smooth_retry(int32_t i32) { this->_i32_smooth_retry = i32; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_smooth_retry(void) { return this->_i32_smooth_retry; }
|
|
otakuto |
c39a2a |
void set_i_same_way_exec_sw(bool sw) { this->_i_same_way_exec_sw = sw; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int exec01020304(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
void exec05_set_middle(void);
|
|
Shinya Kitaoka |
120a6e |
void exec06_int2double_body(void);
|
|
Shinya Kitaoka |
120a6e |
void exec07_smooth_body(void);
|
|
Shinya Kitaoka |
120a6e |
int exec08_expand_lines(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
void exec09_same_way_expand(pixel_select_same_way_root *clp_select);
|
|
Shinya Kitaoka |
120a6e |
void exec10_smooth_expand(void);
|
|
Shinya Kitaoka |
120a6e |
void exec11_set_bbox(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save_not_include(pixel_point_root *clp_pixel_point_root,
|
|
Shinya Kitaoka |
120a6e |
const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_lines(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_one_point(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_middle_point(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_another_point(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save_expand_lines(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_one_expand_point(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_another_expand_point(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
int save_expand_vector(const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw, _i_cv_sw, _i_pv_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double _d_bbox_x_min, _d_bbox_x_max, _d_bbox_y_min, _d_bbox_y_max;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_smooth_retry;
|
|
otakuto |
c39a2a |
bool _i_same_way_exec_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
calculator_geometry _cl_cal_geom;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *_append(pixel_line_node *clp_previous);
|
|
Shinya Kitaoka |
120a6e |
void _remove(pixel_line_node *clp_old);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int _exec01_link_left_right(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
int _exec02_link_up_down(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
int _exec03_link_slant(pixel_point_root *clp_pixel_point_root);
|
|
Shinya Kitaoka |
120a6e |
int _exec04_grouping(pixel_point_root *clp_pixel_point_root);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double _same_way_expand_radian_diff(pixel_point_node *clp_point_middle,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term_expand,
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_root *clp_select);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::exec01020304(pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != this->_exec01_link_left_right(clp_pixel_point_root)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_exec01_link_left_right() returns NG.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != this->_exec02_link_up_down(clp_pixel_point_root)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_exec02_link_up_down() returns NG.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != this->_exec03_link_slant(clp_pixel_point_root)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_exec03_link_slant() returns NG.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != this->_exec04_grouping(clp_pixel_point_root)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_exec04_grouping() returns NG.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::_exec01_link_left_right(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point, *clp_point2;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::_exec01_link_left_right()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
clp_point2 = NULL;
|
|
Shinya Kitaoka |
120a6e |
for (clp_point = (pixel_point_node *)(clp_pixel_point_root->get_clp_first());
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_point2)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
&& (clp_point->get_i32_yp() == clp_point2->get_i32_yp())
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
&& (((clp_point2->get_i32_xp()) + 1) == (clp_point->get_i32_xp()))) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point->link_near(clp_point2)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point2->link_near(clp_point)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point2->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_point2 = clp_point;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" link left right %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::_exec02_link_up_down(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point, *clp_point2;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::_exec02_link_up_down()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_point = (pixel_point_node *)(clp_pixel_point_root->get_clp_first());
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
for (clp_point2 = (pixel_point_node *)clp_point->get_clp_next();
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_point2)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
&& (clp_point2->get_i32_yp() <= (1 + clp_point->get_i32_yp()));
|
|
Shinya Kitaoka |
120a6e |
clp_point2 = (pixel_point_node *)clp_point2->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
if (
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
(clp_point2->get_i32_yp() == (1 + (clp_point->get_i32_yp())))
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
&& (clp_point->get_i32_xp() == clp_point2->get_i32_xp())) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point->link_near(clp_point2)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point2->link_near(clp_point)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point2->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" link up down %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::_exec03_link_slant(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point, *clp_point2, *clp_point_link;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, jj;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
bool i_left_link_sw, i_right_link_sw, i_up_link_sw;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::_exec03_link_slant()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_point = (pixel_point_node *)(clp_pixel_point_root->get_clp_first());
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
/* LINK_NEAR_COUNT個所リンクしているところは、
|
|
Shinya Kitaoka |
120a6e |
これ以上リンクできないので、次へ */
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_point->get_clp_link_near(LINK_NEAR_COUNT - 1)) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
i_left_link_sw = false;
|
|
otakuto |
c39a2a |
i_right_link_sw = false;
|
|
otakuto |
c39a2a |
i_up_link_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < LINK_NEAR_COUNT; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
clp_point_link = clp_point->get_clp_link_near(jj);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_point_link) break;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (((clp_point_link->get_i32_xp()) == (clp_point->get_i32_xp())) &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point_link->get_i32_yp()) == (clp_point->get_i32_yp() + 1))) {
|
|
otakuto |
c39a2a |
i_up_link_sw = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (((clp_point_link->get_i32_xp()) == (clp_point->get_i32_xp() - 1)) &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point_link->get_i32_yp()) == (clp_point->get_i32_yp()))) {
|
|
otakuto |
c39a2a |
i_left_link_sw = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (((clp_point_link->get_i32_xp()) == (clp_point->get_i32_xp() + 1)) &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point_link->get_i32_yp()) == (clp_point->get_i32_yp()))) {
|
|
otakuto |
c39a2a |
i_right_link_sw = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (i_left_link_sw && i_right_link_sw) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (i_up_link_sw) continue;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_point2 = (pixel_point_node *)clp_point->get_clp_next();
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_point2)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
&& (clp_point2->get_i32_yp() <= (1 + clp_point->get_i32_yp()));
|
|
Shinya Kitaoka |
120a6e |
clp_point2 = (pixel_point_node *)clp_point2->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((clp_point2->get_i32_yp()) != (1 + (clp_point->get_i32_yp()))) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (!i_left_link_sw &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point2->get_i32_xp()) == (clp_point->get_i32_xp() - 1)) &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point2->get_i32_yp()) == (clp_point->get_i32_yp() + 1))) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point->link_near(clp_point2)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point2->link_near(clp_point)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point2->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (!i_right_link_sw &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point2->get_i32_xp()) == (clp_point->get_i32_xp() + 1)) &&
|
|
Shinya Kitaoka |
120a6e |
((clp_point2->get_i32_yp()) == (clp_point->get_i32_yp() + 1))) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point->link_near(clp_point2)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NG == clp_point2->link_near(clp_point)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : count %d : clp_point2->link_near() returns NG.", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" link slant %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::_exec04_grouping(pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line_before, *clp_line_crnt;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::_exec04_grouping()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
clp_line_before = NULL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_point = (pixel_point_node *)(clp_pixel_point_root->get_clp_first());
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_point->get_clp_next_point()) ||
|
|
Shinya Kitaoka |
120a6e |
(NULL != clp_point->get_clp_previous_point())) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((NULL != clp_point->get_clp_link_near(0)) &&
|
|
Shinya Kitaoka |
120a6e |
(NULL == clp_point->get_clp_link_near(1))) {
|
|
Shinya Kitaoka |
120a6e |
clp_line_crnt = this->_append(clp_line_before);
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_line_crnt) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_append() returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_line_crnt->link_line(clp_point, clp_point->get_clp_link_near(0),
|
|
Shinya Kitaoka |
120a6e |
clp_pixel_point_root->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_line_crnt->get_i32_point_count() < 3) {
|
|
Shinya Kitaoka |
120a6e |
this->_remove(clp_line_crnt);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
clp_line_before = clp_line_crnt;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" make %d lines", this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec05_set_middle(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec05_set_middle()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_line->set_middle();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" set middle point about %d lines", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec06_int2double_body(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec06_int2double_body()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_line->int2double_body();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" int to double %d lines", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec07_smooth_body(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec07_smooth_body()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" smooth retry %u", this->_i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_line->smooth_body(this->_i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" smooth %d lines", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec10_smooth_expand(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec10_smooth_expand()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" smooth retry %u", this->_i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_line->smooth_expand(this->_i32_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" smooth %d lines", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::exec08_expand_lines(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root *clp_pixel_point_root) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec08_expand_lines()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->expand_line(clp_pixel_point_root)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : line number %d : clp_line->expand_line() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" expand %d lines", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double pixel_line_root::_same_way_expand_radian_diff(
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_middle, pixel_point_node *clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_term_expand,
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_root *clp_select) {
|
|
Shinya Kitaoka |
120a6e |
double d_xv, d_yv;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_middle != clp_point_term);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_term != clp_point_term_expand);
|
|
Shinya Kitaoka |
120a6e |
assert(clp_point_term_expand != clp_point_middle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_select->exec((pixel_line_node *)this->get_clp_first(),
|
|
Shinya Kitaoka |
120a6e |
this->get_i32_count(), clp_point_middle, clp_point_term,
|
|
Shinya Kitaoka |
120a6e |
clp_point_term_expand);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_select->get_i32_count() <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_xv = 0.0;
|
|
Shinya Kitaoka |
120a6e |
d_yv = 0.0;
|
|
Shinya Kitaoka |
120a6e |
clp_select->get_vector(&d_xv, &d_yv);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ベクトルがゼロの場合
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 == d_xv) && (0.0 == d_yv)) {
|
|
Shinya Kitaoka |
120a6e |
return 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_xv +=
|
|
Shinya Kitaoka |
120a6e |
(clp_point_term_expand->get_d_xp_tgt() - clp_point_term->get_d_xp_tgt()) *
|
|
Shinya Kitaoka |
120a6e |
2.0;
|
|
Shinya Kitaoka |
120a6e |
d_yv +=
|
|
Shinya Kitaoka |
120a6e |
(clp_point_term_expand->get_d_yp_tgt() - clp_point_term->get_d_yp_tgt()) *
|
|
Shinya Kitaoka |
120a6e |
2.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return this->_cl_cal_geom.get_d_radian_by_2_vector(
|
|
Shinya Kitaoka |
120a6e |
clp_point_term_expand->get_d_xp_tgt() - clp_point_term->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point_term_expand->get_d_yp_tgt() - clp_point_term->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
d_xv, d_yv);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec09_same_way_expand(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_root *clp_select) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point_start, *clp_point_tmp;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
double d_radian, d_x, d_y;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count_one, i32_count_another;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (!this->_i_same_way_exec_sw) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec09_same_way_expand()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" select max length %g count %d",
|
|
Shinya Kitaoka |
120a6e |
clp_select->get_d_length_max(),
|
|
Shinya Kitaoka |
120a6e |
clp_select->get_i32_count_max());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 各端点(one,anohter)ごと
|
|
Shinya Kitaoka |
120a6e |
同方向線分となる端点の近点を探し、
|
|
Shinya Kitaoka |
120a6e |
それらの合成ベクトルによる角度との差を一時保管する */
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_line->get_clp_link_one_expand()) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = this->_same_way_expand_radian_diff(
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_middle(), clp_line->get_clp_link_one(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_one_expand(), clp_select);
|
|
Shinya Kitaoka |
120a6e |
clp_line->set_d_same_way_radian_one(d_radian);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_line->get_clp_link_another_expand()) {
|
|
Shinya Kitaoka |
120a6e |
d_radian = this->_same_way_expand_radian_diff(
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_middle(), clp_line->get_clp_link_another(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_clp_link_another_expand(), clp_select);
|
|
Shinya Kitaoka |
120a6e |
clp_line->set_d_same_way_radian_another(d_radian);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 各端点(one,anohter)ごと
|
|
Shinya Kitaoka |
120a6e |
伸ばした線分を、一時保管した角度に曲げる */
|
|
Shinya Kitaoka |
120a6e |
i32_count_one = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_count_another = 0;
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (0.0 < clp_line->get_d_same_way_radian_one()) {
|
|
Shinya Kitaoka |
120a6e |
clp_point_start = clp_line->get_clp_link_one();
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp = clp_point_start->get_clp_previous_point();
|
|
Shinya Kitaoka |
120a6e |
for (; NULL != clp_point_tmp;
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp = clp_point_tmp->get_clp_previous_point()) {
|
|
Shinya Kitaoka |
120a6e |
this->_cl_cal_geom.get_dd_rotate_by_pos(
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->get_d_xp_tgt(), clp_point_tmp->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point_start->get_d_xp_tgt(), clp_point_start->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_d_same_way_radian_one(), &d_x, &d_y);
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->set_d_xp_tgt(d_x);
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->set_d_yp_tgt(d_y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_count_one;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (0.0 < clp_line->get_d_same_way_radian_another()) {
|
|
Shinya Kitaoka |
120a6e |
clp_point_start = clp_line->get_clp_link_another();
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp = clp_point_start->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
for (; NULL != clp_point_tmp;
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp = clp_point_tmp->get_clp_next_point()) {
|
|
Shinya Kitaoka |
120a6e |
this->_cl_cal_geom.get_dd_rotate_by_pos(
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->get_d_xp_tgt(), clp_point_tmp->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point_start->get_d_xp_tgt(), clp_point_start->get_d_yp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_d_same_way_radian_another(), &d_x, &d_y);
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->set_d_xp_tgt(d_x);
|
|
Shinya Kitaoka |
120a6e |
clp_point_tmp->set_d_yp_tgt(d_y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_count_another;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_select->mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" same way expand one %d another %d", i32_count_one,
|
|
Shinya Kitaoka |
120a6e |
i32_count_another);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::exec11_set_bbox(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::exec11_set_bbox()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_line->set_bbox();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (0 == ii) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = clp_line->get_d_bbox_x_min();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = clp_line->get_d_bbox_x_max();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = clp_line->get_d_bbox_y_min();
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = clp_line->get_d_bbox_y_max();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (clp_line->get_d_bbox_x_min() < this->_d_bbox_x_min) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min = clp_line->get_d_bbox_x_min();
|
|
Shinya Kitaoka |
120a6e |
} else if (this->_d_bbox_x_max < clp_line->get_d_bbox_x_max()) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max = clp_line->get_d_bbox_x_max();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (clp_line->get_d_bbox_y_min() < this->_d_bbox_y_min) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_min = clp_line->get_d_bbox_y_min();
|
|
Shinya Kitaoka |
120a6e |
} else if (this->_d_bbox_y_max < clp_line->get_d_bbox_y_max()) {
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_y_max = clp_line->get_d_bbox_y_max();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(" set bbox %d lines : min x %g y %g : max x %g y %g", ii,
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_min, this->_d_bbox_y_min,
|
|
Shinya Kitaoka |
120a6e |
this->_d_bbox_x_max, this->_d_bbox_y_max);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *pixel_line_root::_append(pixel_line_node *clp_previous) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_new;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_new = new pixel_line_node;
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_new) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : 'new pixel_line_node' returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_new = (pixel_line_node *)this->push(clp_previous, clp_new);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return clp_new;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::_remove(pixel_line_node *clp_old) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_old);
|
|
Shinya Kitaoka |
120a6e |
this->pop(clp_old);
|
|
Shinya Kitaoka |
120a6e |
delete clp_old;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void pixel_line_root::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->get_clp_last()) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_line_root::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
while (NULL != (clp_ = (pixel_line_node *)this->get_clp_last())) {
|
|
Shinya Kitaoka |
120a6e |
this->_remove(clp_);
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("free line node %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_not_include(pixel_point_root *clp_pixel_point_root,
|
|
Shinya Kitaoka |
120a6e |
const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_not_include_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# all point count %d\n",
|
|
Shinya Kitaoka |
120a6e |
clp_pixel_point_root->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# all point count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_not_include_line = 0;
|
|
Shinya Kitaoka |
120a6e |
for (clp_point = (pixel_point_node *)(clp_pixel_point_root->get_clp_first()),
|
|
Shinya Kitaoka |
120a6e |
ii = 0L;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_point;
|
|
Shinya Kitaoka |
120a6e |
clp_point = (pixel_point_node *)clp_point->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if ((NULL == clp_point->get_clp_next_point()) &&
|
|
Shinya Kitaoka |
120a6e |
(NULL == clp_point->get_clp_previous_point())) {
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%d %d\n", clp_point->get_i32_xp(),
|
|
Shinya Kitaoka |
120a6e |
clp_point->get_i32_yp()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(%d %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
clp_point->get_i32_xp(), clp_point->get_i32_yp());
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_not_include_line;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# not include is %d\n", i32_not_include_line) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# not include is %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
i32_not_include_line);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_lines(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# lines count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d and points count %d\n", ii,
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_i32_point_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_line(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_line() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_line->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
/* 2行の改行(for gnuplot)保存 */
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "\n\n") < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(LF,LF) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_one_point(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d ... start point\n", ii) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_one_point(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_one_point() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_middle_point(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d ... start point\n", ii) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_middle_point(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_middle_point() returns NG",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_another_point(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d ... end point\n", ii) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_another_point(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_another_point() returns NG",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_expand_lines(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# lines count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d and points count %d\n", ii,
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_i32_point_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_expand_line(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_line() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != clp_line->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
/* 2行の改行(for gnuplot)保存 */
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "\n\n") < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(LF,LF) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_one_expand_point(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d ... one expand point\n", ii) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_one_expand_point(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : clp_line->save_one_expand_point() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_another_expand_point(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d ... another expand point\n", ii) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_another_expand_point(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : clp_line->save_another_expand_point() returns NG", ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_line_root::save_expand_vector(const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# lines count %d\n", this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# group count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)this->get_clp_first(), ii = 0;
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# line number %d and points count %d\n", ii,
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_i32_point_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# line number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != clp_line->save_expand_vector(fp)) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : clp_line->save_expand_vector() returns NG");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _pixel_select_curve_blur_h_
|
|
Toshihiro Shimizu |
890ddd |
#define _pixel_select_curve_blur_h_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "list_root.h" "calculator_geometry.h" "pixel_point_root.h" "pixel_line_root.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_select_curve_blur_node final : public list_node {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node(void) {
|
|
Shinya Kitaoka |
120a6e |
this->clp_line = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->clp_start_point = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->clp_near_point = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->i32_near_point_pos = 0;
|
|
Shinya Kitaoka |
120a6e |
this->d_length = -1.0;
|
|
otakuto |
c39a2a |
this->i_reverse_sw = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void copy(pixel_select_curve_blur_node *clp) {
|
|
Shinya Kitaoka |
120a6e |
this->clp_line = clp->clp_line;
|
|
Shinya Kitaoka |
120a6e |
this->clp_start_point = clp->clp_start_point;
|
|
Shinya Kitaoka |
120a6e |
this->clp_near_point = clp->clp_near_point;
|
|
Shinya Kitaoka |
120a6e |
this->i32_near_point_pos = clp->i32_near_point_pos;
|
|
Shinya Kitaoka |
120a6e |
this->d_length = clp->d_length;
|
|
Shinya Kitaoka |
120a6e |
this->i_reverse_sw = clp->i_reverse_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_start_point;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_near_point;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_near_point_pos;
|
|
Shinya Kitaoka |
120a6e |
double d_length;
|
|
otakuto |
c39a2a |
bool i_reverse_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class pixel_select_curve_blur_root final : public list_root {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_root(void) {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count_max = 4;
|
|
Shinya Kitaoka |
120a6e |
this->_d_length_max = 160;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~pixel_select_curve_blur_root(void) { this->mem_free(); }
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool sw) { this->_i_mv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool sw) { this->_i_cv_sw = sw; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool sw) { this->_i_pv_sw = sw; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_count_max(void) { return this->_i32_count_max; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_count_max(int32_t ii) { this->_i32_count_max = ii; }
|
|
Shinya Kitaoka |
120a6e |
double get_d_length_max(void) { return this->_d_length_max; }
|
|
Shinya Kitaoka |
120a6e |
void set_d_length_max(double dd) { this->_d_length_max = dd; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void exec(double d_xp, double d_yp, pixel_line_root *clp_pixel_line_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_blur_count, double d_effect_length_radius);
|
|
Shinya Kitaoka |
120a6e |
/******void exec( double d_xp, double d_yp, pixel_line_node *clp_line_first,
|
|
Shinya Kitaoka |
120a6e |
* int32_t i32_count, int32_t i32_blur_count, double d_effect_length_radius
|
|
Shinya Kitaoka |
120a6e |
* );******/
|
|
Shinya Kitaoka |
120a6e |
int get_line(int32_t i32_blur_count, double *dp_xv, double *dp_yv);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int save(double d_xp, double d_yp, int32_t i32_blur_count,
|
|
Shinya Kitaoka |
120a6e |
const char *cp_fname);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw, _i_cv_sw, _i_pv_sw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_count_max;
|
|
Shinya Kitaoka |
120a6e |
double _d_length_max;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
calculator_geometry _cl_cal_geom;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *_append(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_previous);
|
|
Shinya Kitaoka |
120a6e |
void _remove(pixel_select_curve_blur_node *clp_old);
|
|
Shinya Kitaoka |
120a6e |
int _sort_append(pixel_select_curve_blur_node *clp_src);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_get_next_points(pixel_point_node *clp_point,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *_get_prev_points(pixel_point_node *clp_point,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double _get_line_accum_count(pixel_select_curve_blur_node *clp_select,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_blur_count);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h> /* exit() */</stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* M_PI */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#define M_PI 3.14159265358979323846
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_line_root.h" "pixel_select_curve_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *pixel_select_curve_blur_root::_append(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_previous) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_new;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
clp_new = new pixel_select_curve_blur_node;
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_new) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr(
|
|
Shinya Kitaoka |
120a6e |
"Error : 'new pixel_select_curve_blur_node' returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_new = (pixel_select_curve_blur_node *)this->push(clp_previous, clp_new);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return clp_new;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_curve_blur_root::_remove(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_old) {
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_old);
|
|
Shinya Kitaoka |
120a6e |
this->pop(clp_old);
|
|
Shinya Kitaoka |
120a6e |
delete clp_old;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_curve_blur_root::mem_free(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->get_clp_last()) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("pixel_select_curve_blur_root::mem_free()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
while (NULL != this->get_clp_last()) {
|
|
Shinya Kitaoka |
120a6e |
this->_remove((pixel_select_curve_blur_node *)this->get_clp_last());
|
|
Shinya Kitaoka |
120a6e |
++ii;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("free select curve blur node %d", ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* lengthの値を見て、距離の近い(小さい値)順になるように追加する
|
|
Shinya Kitaoka |
120a6e |
すべての選択リストより小さいなら先頭
|
|
Shinya Kitaoka |
120a6e |
すべての選択リストより大きいなら最後に追加
|
|
Shinya Kitaoka |
120a6e |
値から選択リストの間に入るならそこに追加
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
int pixel_select_curve_blur_root::_sort_append(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_src) {
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_prev;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0.0 < clp_src->d_length);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev = (pixel_select_curve_blur_node *)this->get_clp_last();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; NULL != clp_prev; ++ii,
|
|
Shinya Kitaoka |
120a6e |
clp_prev = (pixel_select_curve_blur_node *)clp_prev->get_clp_previous()) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
if (clp_prev->d_length < clp_src->d_length) {
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev = this->_append(clp_prev);
|
|
Shinya Kitaoka |
120a6e |
if (NULL == clp_prev) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : this->_append(clp_prev) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_prev->copy(clp_src);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
#define NOT_USE_PARAMETER_VAL (-10000.0)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void pixel_select_curve_blur_root::exec(double d_xp, double d_yp,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root *clp_pixel_line_root,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_blur_count,
|
|
Shinya Kitaoka |
120a6e |
double d_effect_area_radius) {
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, i32_pos;
|
|
otakuto |
c39a2a |
bool i_reverse_sw;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_near_point, *clp_start_point;
|
|
Shinya Kitaoka |
120a6e |
double d_length, d_radius, d_radius_1st;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node cl_select;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((d_xp <
|
|
Shinya Kitaoka |
120a6e |
(clp_pixel_line_root->get_d_bbox_x_min() - d_effect_area_radius)) ||
|
|
Shinya Kitaoka |
120a6e |
((clp_pixel_line_root->get_d_bbox_x_max() + d_effect_area_radius) <
|
|
Shinya Kitaoka |
120a6e |
d_xp) ||
|
|
Shinya Kitaoka |
120a6e |
(d_yp <
|
|
Shinya Kitaoka |
120a6e |
(clp_pixel_line_root->get_d_bbox_y_min() - d_effect_area_radius)) ||
|
|
Shinya Kitaoka |
120a6e |
((clp_pixel_line_root->get_d_bbox_y_max() + d_effect_area_radius) <
|
|
Shinya Kitaoka |
120a6e |
d_yp)) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radius_1st = NOT_USE_PARAMETER_VAL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ii = 0;
|
|
Shinya Kitaoka |
120a6e |
for (clp_line = (pixel_line_node *)clp_pixel_line_root->get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(ii < clp_pixel_line_root->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_middle());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_one());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_line->get_clp_link_another());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(clp_line->get_clp_link_middle() != clp_line->get_clp_link_one());
|
|
Shinya Kitaoka |
120a6e |
assert(clp_line->get_clp_link_middle() != clp_line->get_clp_link_another());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((d_xp < (clp_line->get_d_bbox_x_min() - d_effect_area_radius)) ||
|
|
Shinya Kitaoka |
120a6e |
((clp_line->get_d_bbox_x_max() + d_effect_area_radius) < d_xp) ||
|
|
Shinya Kitaoka |
120a6e |
(d_yp < (clp_line->get_d_bbox_y_min() - d_effect_area_radius)) ||
|
|
Shinya Kitaoka |
120a6e |
((clp_line->get_d_bbox_y_max() + d_effect_area_radius) < d_yp)) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_near_point(d_xp, d_yp, &i32_pos, &clp_near_point, &d_length);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (this->_d_length_max < d_length) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 線分の端で必要な長さがとれない
|
|
Shinya Kitaoka |
120a6e |
画面の端の場合、問題あり!!!!!!
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
if ((i32_pos < (i32_blur_count / 2)) ||
|
|
Shinya Kitaoka |
120a6e |
((clp_line->get_i32_point_count() - 1 - i32_pos) <
|
|
Shinya Kitaoka |
120a6e |
(i32_blur_count / 2))) {
|
|
Shinya Kitaoka |
120a6e |
continue;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
i_reverse_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_start_point =
|
|
Shinya Kitaoka |
120a6e |
clp_line->get_prev_point_by_count(clp_near_point, i32_blur_count / 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_radius = this->_cl_cal_geom.get_d_radian(
|
|
Shinya Kitaoka |
120a6e |
clp_start_point->get_d_xp_tgt() - clp_near_point->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_start_point->get_d_yp_tgt() - clp_near_point->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NOT_USE_PARAMETER_VAL == d_radius_1st) {
|
|
Shinya Kitaoka |
120a6e |
d_radius_1st = d_radius;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/* 2番目以後は記憶した方向との比較し
|
|
Shinya Kitaoka |
120a6e |
線の対応部分の、方向と開始点を最設定 */
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (d_radius < d_radius_1st) {
|
|
Shinya Kitaoka |
120a6e |
d_radius += M_PI * 2.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
d_radius -= d_radius_1st;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((M_PI / 2.0 < d_radius) && (d_radius < M_PI * 3.0 / 2.0)) {
|
|
Shinya Kitaoka |
120a6e |
clp_start_point = clp_line->get_next_point_by_count(clp_near_point,
|
|
Shinya Kitaoka |
120a6e |
i32_blur_count / 2);
|
|
otakuto |
c39a2a |
i_reverse_sw = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_line = clp_line;
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_start_point = clp_start_point;
|
|
Shinya Kitaoka |
120a6e |
cl_select.clp_near_point = clp_near_point;
|
|
Shinya Kitaoka |
120a6e |
cl_select.i32_near_point_pos = i32_pos;
|
|
Shinya Kitaoka |
120a6e |
cl_select.d_length = d_length;
|
|
Shinya Kitaoka |
120a6e |
cl_select.i_reverse_sw = i_reverse_sw;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_sort_append(&cl_select);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*****if ((NULL != this->get_clp_first()) && (510.0 < d_xp) && (100.0 < d_yp))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//if (NULL != this->get_clp_first()) {
|
|
Shinya Kitaoka |
120a6e |
this->save( d_xp, d_yp, i32_blur_count,"tmp19_select.txt" ); exit(1); }
|
|
Toshihiro Shimizu |
890ddd |
******/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/********************************************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double pixel_select_curve_blur_root::_get_line_accum_count(
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_select, int32_t i32_blur_count) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_pos, i32_count;
|
|
Shinya Kitaoka |
120a6e |
double d_ratio;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
i32_pos = clp_select->i32_near_point_pos - (i32_blur_count / 2);
|
|
Shinya Kitaoka |
120a6e |
i32_count = clp_select->clp_line->get_i32_point_count() -
|
|
Shinya Kitaoka |
120a6e |
(i32_blur_count / 2) - (i32_blur_count / 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= i32_pos);
|
|
Shinya Kitaoka |
120a6e |
assert(0 < i32_count);
|
|
Shinya Kitaoka |
120a6e |
assert(i32_pos < i32_count);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/**if (i32_pos < (i32_count/2)) {
|
|
Shinya Kitaoka |
120a6e |
d_ratio = (double)(i32_pos+1) / (i32_count/2);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
d_ratio = (double)(i32_count-i32_pos) / (i32_count/2);
|
|
Shinya Kitaoka |
120a6e |
}**/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_ratio = ((double)i32_pos + 0.5) / (double)i32_count;
|
|
Shinya Kitaoka |
120a6e |
/* sinカーブ
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_ratio = 1.0 + sin(2.0 * M_PI * d_ratio - M_PI / 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
assert(0.0 < d_ratio);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return d_ratio;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 距離の近い順(lengthの小さい値)に指定個数分のベクトルを合成して返す
|
|
Shinya Kitaoka |
120a6e |
先頭から
|
|
Shinya Kitaoka |
120a6e |
this->_i32_count_max数個分
|
|
Shinya Kitaoka |
120a6e |
のベクトルを合成する
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
int pixel_select_curve_blur_root::get_line(int32_t i32_blur_count,
|
|
Shinya Kitaoka |
120a6e |
double *dp_xv, double *dp_yv) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, jj, i32_count;
|
|
Shinya Kitaoka |
120a6e |
double d_xp, d_yp;
|
|
Shinya Kitaoka |
120a6e |
double d_ratio, d_accum;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_select;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < i32_blur_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
dp_xv[ii] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
dp_yv[ii] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_count = 0;
|
|
Shinya Kitaoka |
120a6e |
d_accum = 0.0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_select = (pixel_select_curve_blur_node *)this->get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; (NULL != clp_select) && (ii < this->_i32_count_max); ++ii,
|
|
Shinya Kitaoka |
120a6e |
++i32_count,
|
|
Shinya Kitaoka |
120a6e |
clp_select = (pixel_select_curve_blur_node *)clp_select->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_select->clp_line);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_select->clp_start_point);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_select->clp_near_point);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_ratio = this->_get_line_accum_count(clp_select, i32_blur_count);
|
|
Shinya Kitaoka |
120a6e |
d_accum += d_ratio;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_xp = clp_select->clp_near_point->get_d_xp_tgt();
|
|
Shinya Kitaoka |
120a6e |
d_yp = clp_select->clp_near_point->get_d_yp_tgt();
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_select->clp_start_point;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (!clp_select->i_reverse_sw) {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < i32_blur_count; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
dp_xv[jj] += (clp_point->get_d_xp_tgt() - d_xp) * d_ratio;
|
|
Shinya Kitaoka |
120a6e |
dp_yv[jj] += (clp_point->get_d_yp_tgt() - d_yp) * d_ratio;
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_point->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < i32_blur_count; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
dp_xv[jj] += (clp_point->get_d_xp_tgt() - d_xp) * d_ratio;
|
|
Shinya Kitaoka |
120a6e |
dp_yv[jj] += (clp_point->get_d_yp_tgt() - d_yp) * d_ratio;
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_point->get_clp_previous_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (i32_count <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(0.0 < d_accum);
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; ii < i32_blur_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
dp_xv[ii] /= d_accum;
|
|
Shinya Kitaoka |
120a6e |
dp_yv[ii] /= d_accum;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "pixel_select_curve_blur.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int pixel_select_curve_blur_root::save(double d_xp, double d_yp,
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_blur_count,
|
|
Shinya Kitaoka |
120a6e |
const char *cp_fname) {
|
|
Shinya Kitaoka |
120a6e |
FILE *fp;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, jj;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_node *clp_loop;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_point;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fp = fopen(cp_fname, "w");
|
|
Shinya Kitaoka |
120a6e |
if (NULL == fp) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fopen(%s,w) returns NULL", cp_fname);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# blur point count %d\n", i32_blur_count) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# blur point count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# select count %d in %d\n", this->_i32_count_max,
|
|
Shinya Kitaoka |
120a6e |
this->get_i32_count()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# select count) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_curve_blur_node *)this->get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0; (NULL != clp_loop) && (ii < this->_i32_count_max); ++ii,
|
|
Shinya Kitaoka |
120a6e |
clp_loop = (pixel_select_curve_blur_node *)clp_loop->get_clp_next()) {
|
|
Shinya Kitaoka |
120a6e |
assert(ii < this->get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop->clp_line);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop->clp_start_point);
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != clp_loop->clp_near_point);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "# selct number %d : reverse sw is %s\n", ii,
|
|
otakuto |
c39a2a |
(!clp_loop->i_reverse_sw ? "off" : "on")) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(# line number %d) returns minus",
|
|
Shinya Kitaoka |
120a6e |
ii);
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_loop->clp_near_point;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_point->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(near point) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n\n\n", d_xp, d_yp) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(pixel point) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_loop->clp_start_point;
|
|
otakuto |
c39a2a |
if (!clp_loop->i_reverse_sw) {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < i32_blur_count; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_point->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(x,y) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_point->get_clp_next_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < i32_blur_count; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "%g %g\n", clp_point->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_point->get_d_yp_tgt()) < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(x,y) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
clp_point = clp_point->get_clp_previous_point();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (fprintf(fp, "\n\n") < 0) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : fprintf(EnterEnter) returns minus");
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
fclose(fp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#ifndef __thinnest_ui16_image_h__
|
|
Shinya Kitaoka |
120a6e |
#define __thinnest_ui16_image_h__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <stdio.h></stdio.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
 |
e280ae |
#if defined _MSC_VER
|
|
Shinya Kitaoka |
120a6e |
typedef int int32_t;
|
|
Shinya Kitaoka |
120a6e |
typedef unsigned short uint16_t;
|
|
Shinya Kitaoka |
120a6e |
#else
|
|
Shinya Kitaoka |
120a6e |
#include <stdint.h> /* for int32_t, uint16_t */</stdint.h>
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#ifndef UINT16_MAX
|
|
Shinya Kitaoka |
120a6e |
#define UINT16_MAX (65535)
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#ifndef OK
|
|
Shinya Kitaoka |
120a6e |
#define OK (0)
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Shinya Kitaoka |
120a6e |
#ifndef NG
|
|
Shinya Kitaoka |
120a6e |
#define NG (-1)
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class thinnest_ui16_image {
|
|
Shinya Kitaoka |
120a6e |
public:
|
|
Shinya Kitaoka |
120a6e |
thinnest_ui16_image() {
|
|
otakuto |
c39a2a |
this->_i_mv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_pv_sw = false;
|
|
otakuto |
c39a2a |
this->_i_cv_sw = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xs = 0;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_ys = 0;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xd = 1;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_yd = 1;
|
|
Shinya Kitaoka |
120a6e |
this->_ui16_threshold = (uint16_t)0x4000;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_exec_loop_count = 100;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[0] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[1] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->memory_free_this_ = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
~thinnest_ui16_image() { this->mem_free(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
void set_i_mv_sw(bool ii) { this->_i_mv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_pv_sw(bool ii) { this->_i_pv_sw = ii; }
|
|
otakuto |
c39a2a |
void set_i_cv_sw(bool ii) { this->_i_cv_sw = ii; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void set_i32_xs(int32_t ii) { this->_i32_xs = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_ys(int32_t ii) { this->_i32_ys = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_xd(int32_t ii) { this->_i32_xd = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_yd(int32_t ii) { this->_i32_yd = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_ui16_threshold(uint16_t ii) { this->_ui16_threshold = ii; }
|
|
Shinya Kitaoka |
120a6e |
void set_i32_exec_loop_count(int32_t ii) { this->_i32_exec_loop_count = ii; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_xs(void) { return this->_i32_xs; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_ys(void) { return this->_i32_ys; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_xd(void) { return this->_i32_xd; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_yd(void) { return this->_i32_yd; }
|
|
Shinya Kitaoka |
120a6e |
uint16_t get_ui16_threshold(void) { return this->_ui16_threshold; }
|
|
Shinya Kitaoka |
120a6e |
int32_t get_i32_exec_loop_count(void) { return this->_i32_exec_loop_count; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int mem_alloc(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t exec01_fill_noise_pixel(void);
|
|
Shinya Kitaoka |
120a6e |
void exec02_scale_add_edge_pixel(void);
|
|
Shinya Kitaoka |
120a6e |
void exec03_scale_liner(void);
|
|
Shinya Kitaoka |
120a6e |
void exec04_bw(void);
|
|
Shinya Kitaoka |
120a6e |
int exec05_thin(void);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
uint16_t *get_ui16p_src_channel(void) { return this->_ui16p_channel[0]; }
|
|
Shinya Kitaoka |
120a6e |
uint16_t *get_ui16p_tgt_channel(void) { return this->_ui16p_channel[1]; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void mem_free(void);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
private:
|
|
otakuto |
c39a2a |
bool _i_mv_sw;
|
|
otakuto |
c39a2a |
bool _i_pv_sw;
|
|
otakuto |
c39a2a |
bool _i_cv_sw;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_xs, _i32_ys,
|
|
Shinya Kitaoka |
120a6e |
_i32_xd, _i32_yd;
|
|
Shinya Kitaoka |
120a6e |
uint16_t _ui16_threshold;
|
|
Shinya Kitaoka |
120a6e |
int32_t _i32_exec_loop_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
uint16_t *memory_free_this_;
|
|
Shinya Kitaoka |
120a6e |
uint16_t *_ui16p_channel[2];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void _swap_channel(void) {
|
|
Shinya Kitaoka |
120a6e |
uint16_t *_ui16p_tmp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
_ui16p_tmp = this->_ui16p_channel[0];
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[0] = this->_ui16p_channel[1];
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[1] = _ui16p_tmp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t _exec01_fill_noise_pixel_scanline(uint16_t *ui16p_y1,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_y2,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_y3);
|
|
Shinya Kitaoka |
120a6e |
int32_t _exec01_fill_noise_pixel_pixel(
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x1a, uint16_t *ui16p_x1b, uint16_t *ui16p_x1c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x2a, uint16_t *ui16p_x2b, uint16_t *ui16p_x2c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x3a, uint16_t *ui16p_x3b, uint16_t *ui16p_x3c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t _one_side_thinner(void);
|
|
Shinya Kitaoka |
120a6e |
int32_t _one_side_thinner_scanline(uint16_t *ui16p_src_y1,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_y2,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_y3,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_tgt);
|
|
Shinya Kitaoka |
120a6e |
int32_t _one_side_thinner_pixel(
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x1a, uint16_t *ui16p_src_x1b, uint16_t *ui16p_src_x1c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x2a, uint16_t *ui16p_src_x2b, uint16_t *ui16p_src_x2c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x3a, uint16_t *ui16p_src_x3b, uint16_t *ui16p_src_x3c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_tgt);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void _rot90_by_clockwork(void);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::exec01_fill_noise_pixel(void) {
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_y1, *ui16p_y2, *ui16p_y3;
|
|
Shinya Kitaoka |
120a6e |
int32_t yy, i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::exec01_fill_noise_pixel()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(this->_i32_ys);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_y1 = this->get_ui16p_src_channel() + this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_y2 = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_y3 = NULL;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_fill_count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_fill_count +=
|
|
Shinya Kitaoka |
120a6e |
this->_exec01_fill_noise_pixel_scanline(ui16p_y1, ui16p_y2, ui16p_y3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_y3 = ui16p_y2;
|
|
Shinya Kitaoka |
120a6e |
ui16p_y2 = ui16p_y1;
|
|
Shinya Kitaoka |
120a6e |
if ((yy + 1) < (this->_i32_ys)) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_y1 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
ui16p_y1 = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::_exec01_fill_noise_pixel_scanline(
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_y1, uint16_t *ui16p_y2, uint16_t *ui16p_y3) {
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x1a, *ui16p_x1b, *ui16p_x1c, *ui16p_x2a, *ui16p_x2b,
|
|
Shinya Kitaoka |
120a6e |
*ui16p_x2c, *ui16p_x3a, *ui16p_x3b, *ui16p_x3c;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1c = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2c = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3c = NULL;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_y1) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1a = ui16p_y1 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1b = ui16p_y1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_y2) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2a = ui16p_y2 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2b = ui16p_y2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_y3) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3a = ui16p_y3 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3b = ui16p_y3;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_fill_count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
i32_fill_count += this->_exec01_fill_noise_pixel_pixel(
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1a, ui16p_x1b, ui16p_x1c, ui16p_x2a, ui16p_x2b, ui16p_x2c,
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3a, ui16p_x3b, ui16p_x3c);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1c = ui16p_x1b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1b = ui16p_x1a;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2c = ui16p_x2b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2b = ui16p_x2a;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3c = ui16p_x3b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3b = ui16p_x3a;
|
|
Shinya Kitaoka |
120a6e |
if ((xx + 1) < (this->_i32_xs)) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x1a)) ++ui16p_x1a;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x2a)) ++ui16p_x2a;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x3a)) ++ui16p_x3a;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
ui16p_x1a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x2a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_x3a = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::_exec01_fill_noise_pixel_pixel(
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x1a, uint16_t *ui16p_x1b, uint16_t *ui16p_x1c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x2a, uint16_t *ui16p_x2b, uint16_t *ui16p_x2c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_x3a, uint16_t *ui16p_x3b, uint16_t *ui16p_x3c) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_exist_count, i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != ui16p_x2b);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_fill_count = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_eqgt_count = 0L;
|
|
Shinya Kitaoka |
120a6e |
i32_exist_count = 0L;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x1a)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x1a)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x1b)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x1b)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x1c)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x1c)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x2c)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x2c)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x3c)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x3c)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x3b)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x3b)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x3a)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x3a)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_x2a)) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= (*ui16p_x2a)) {
|
|
Shinya Kitaoka |
120a6e |
++i32_eqgt_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++i32_exist_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (i32_exist_count == i32_eqgt_count) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_x2b = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
++i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_fill_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void thinnest_ui16_image::exec02_scale_add_edge_pixel(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, i32_tmp1, i32_tmp2;
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src, *ui16p_src1, *ui16p_src2, *ui16p_tgt, *ui16p_tgt1,
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((this->_i32_xs < 2) || (this->_i32_ys < 2) || (this->_i32_xd < 2) ||
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_yd < 2)) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::exec02_scale_add_edge_pixel()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(this->_i32_ys);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt1 = this->get_ui16p_tgt_channel() + (this->_i32_xs + 2) + 1;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt2 = ui16p_tgt1;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt2 = *ui16p_src;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_tgt2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt1 += (this->_i32_xs + 2);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 = this->get_ui16p_src_channel() + this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel() + 1;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 = (int32_t)(*ui16p_src1);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp2 = (int32_t)(*ui16p_src2);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 *= 2;
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 -= i32_tmp2;
|
|
Shinya Kitaoka |
120a6e |
if (i32_tmp1 < 0) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
} else if ((int32_t)UINT16_MAX < i32_tmp1) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = (uint16_t)i32_tmp1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src1;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src2;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 =
|
|
Shinya Kitaoka |
120a6e |
this->get_ui16p_src_channel() + ((this->_i32_ys - 1) * this->_i32_xs);
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 =
|
|
Shinya Kitaoka |
120a6e |
this->get_ui16p_src_channel() + ((this->_i32_ys - 2) * this->_i32_xs);
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel() +
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_ys + 2 - 1) * (this->_i32_xs + 2) + 1;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 = (int32_t)(*ui16p_src1);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp2 = (int32_t)(*ui16p_src2);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 *= 2;
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 -= i32_tmp2;
|
|
Shinya Kitaoka |
120a6e |
if (i32_tmp1 < 0) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
} else if ((int32_t)UINT16_MAX < i32_tmp1) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = (uint16_t)i32_tmp1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src1;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src2;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 = this->get_ui16p_src_channel() + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel() + (this->_i32_xs + 2);
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 = (int32_t)(*ui16p_src1);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp2 = (int32_t)(*ui16p_src2);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 *= 2;
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 -= i32_tmp2;
|
|
Shinya Kitaoka |
120a6e |
if (i32_tmp1 < 0) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
} else if ((int32_t)UINT16_MAX < i32_tmp1) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = (uint16_t)i32_tmp1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt += (this->_i32_xs + 2);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 = this->get_ui16p_src_channel() + this->_i32_xs - 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 = this->get_ui16p_src_channel() + this->_i32_xs - 1 - 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel() + (this->_i32_xs + 2) * 2 - 1;
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 = (int32_t)(*ui16p_src1);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp2 = (int32_t)(*ui16p_src2);
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 *= 2;
|
|
Shinya Kitaoka |
120a6e |
i32_tmp1 -= i32_tmp2;
|
|
Shinya Kitaoka |
120a6e |
if (i32_tmp1 < 0) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
} else if ((int32_t)UINT16_MAX < i32_tmp1) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = (uint16_t)i32_tmp1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src1 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src2 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt += (this->_i32_xs + 2);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xs += 2;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_ys += 2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_swap_channel();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include <math.h> /* floor(), ceil() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void thinnest_ui16_image::exec03_scale_liner(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy, i32_tgt_xs, i32_tgt_ys;
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src, *ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
double d_src_xp, d_src_yp, d_tgt_xp, d_tgt_yp;
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_src_xpos1, i32_src_ypos1, i32_src_xpos2, i32_src_ypos2;
|
|
Shinya Kitaoka |
120a6e |
double d_src_xratio1, d_src_yratio1, d_src_xratio2, d_src_yratio2;
|
|
Shinya Kitaoka |
120a6e |
double d_tmp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((this->_i32_xs < 2) || (this->_i32_ys < 2) || (this->_i32_xd < 2) ||
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_yd < 2)) {
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::exec03_scale_liner()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thi : Scale %d x %d", this->_i32_xd, this->_i32_yd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start((this->_i32_ys - 2) * this->_i32_yd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_tgt_ys = (this->_i32_ys - 2) * this->_i32_yd;
|
|
Shinya Kitaoka |
120a6e |
i32_tgt_xs = (this->_i32_xs - 2) * this->_i32_xd;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < i32_tgt_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < i32_tgt_xs; ++xx, ++ui16p_tgt) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
画像scaleのピクセルの対応図
|
|
Shinya Kitaoka |
120a6e |
(3倍拡大の場合)
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| + |外周付加
|
|
Shinya Kitaoka |
120a6e |
| |ピクセル
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | +
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| + | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | +
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | +
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| + | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | +
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
| | --> | + |
|
|
Shinya Kitaoka |
120a6e |
| | | |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| + |外周付加
|
|
Shinya Kitaoka |
120a6e |
| |ピクセル
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
| |
|
|
Shinya Kitaoka |
120a6e |
+
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_tgt_xp = ((double)xx + 0.5) / (double)i32_tgt_xs;
|
|
Shinya Kitaoka |
120a6e |
d_tgt_yp = ((double)yy + 0.5) / (double)i32_tgt_ys;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_src_xp = ((double)(this->_i32_xs) - 2.0) * d_tgt_xp + 0.5;
|
|
Shinya Kitaoka |
120a6e |
d_src_yp = ((double)(this->_i32_ys) - 2.0) * d_tgt_yp + 0.5;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_src_xpos1 = (int32_t)floor(d_src_xp);
|
|
Shinya Kitaoka |
120a6e |
i32_src_ypos1 = (int32_t)floor(d_src_yp);
|
|
Shinya Kitaoka |
120a6e |
i32_src_xpos2 = (int32_t)ceil(d_src_xp);
|
|
Shinya Kitaoka |
120a6e |
i32_src_ypos2 = (int32_t)ceil(d_src_yp);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (i32_src_xpos1 == i32_src_xpos2) {
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio1 = 0.0;
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio2 = 1.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio1 = d_src_xp - floor(d_src_xp);
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio2 = ceil(d_src_xp) - d_src_xp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (i32_src_ypos1 == i32_src_ypos2) {
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio1 = 0.0;
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio2 = 1.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio1 = d_src_yp - floor(d_src_yp);
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio2 = ceil(d_src_yp) - d_src_yp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
d_tmp = ((ui16p_src[this->_i32_xs * i32_src_ypos1 + i32_src_xpos1] *
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio2 +
|
|
Shinya Kitaoka |
120a6e |
ui16p_src[this->_i32_xs * i32_src_ypos1 + i32_src_xpos2] *
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio1) *
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio2 +
|
|
Shinya Kitaoka |
120a6e |
(ui16p_src[this->_i32_xs * i32_src_ypos2 + i32_src_xpos1] *
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio2 +
|
|
Shinya Kitaoka |
120a6e |
ui16p_src[this->_i32_xs * i32_src_ypos2 + i32_src_xpos2] *
|
|
Shinya Kitaoka |
120a6e |
d_src_xratio1) *
|
|
Shinya Kitaoka |
120a6e |
d_src_yratio1);
|
|
Shinya Kitaoka |
120a6e |
if (UINT16_MAX <= d_tmp) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt[0] = (uint16_t)UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt[0] = (uint16_t)d_tmp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xs = (this->_i32_xs - 2) * this->_i32_xd;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_ys = (this->_i32_ys - 2) * this->_i32_yd;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_swap_channel();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void thinnest_ui16_image::exec04_bw(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy;
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src, *ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::exec04_bw()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thi : threshold %u", this->_ui16_threshold);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(this->_i32_ys);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0L; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0L; xx < this->_i32_xs; ++xx, ++ui16p_src, ++ui16p_tgt) {
|
|
Shinya Kitaoka |
120a6e |
if (this->_ui16_threshold <= *ui16p_src) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = UINT16_MAX;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_swap_channel();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int thinnest_ui16_image::exec05_thin(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t ii, jj, i32_pixel_count_total, i32_pixel_count_one_round,
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side_tmp, i32_pixel_count_one_side[4];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::exec05_thin()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_total = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[0] = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[1] = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[2] = 0;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[3] = 0;
|
|
Shinya Kitaoka |
120a6e |
for (ii = 0;; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (this->get_i32_exec_loop_count() <= ii) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : loop counter over %ld.",
|
|
Shinya Kitaoka |
120a6e |
this->get_i32_exec_loop_count());
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_round = 0;
|
|
Shinya Kitaoka |
120a6e |
for (jj = 0; jj < 4; ++jj) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side_tmp = this->_one_side_thinner();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_round += i32_pixel_count_one_side_tmp;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_total += i32_pixel_count_one_side_tmp;
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[jj] += i32_pixel_count_one_side_tmp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_rot90_by_clockwork();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, ".");
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/* カウントダウン表示(上下左右やって"....|"となる) */
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "|");
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (9 == (ii % 10)) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "\n");
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (i32_pixel_count_one_round <= 0) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
(void)fprintf(stdout, "\nthin line ... end.\n");
|
|
Shinya Kitaoka |
120a6e |
(void)fflush(stdout);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thi : total %d loop, and %ld pixel deleted", ii,
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_total);
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(
|
|
Shinya Kitaoka |
120a6e |
"thi : and each r<%ld>+ t<%ld>+ l<%ld>+ b<%ld> pixel deleted",
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[0], i32_pixel_count_one_side[1],
|
|
Shinya Kitaoka |
120a6e |
i32_pixel_count_one_side[2], i32_pixel_count_one_side[3]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <stdlib.h> /* free(), calloc() */</stdlib.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void thinnest_ui16_image::mem_free(void) {
|
|
Toshihiro Shimizu |
890ddd |
#if 0
|
|
Toshihiro Shimizu |
890ddd |
if (NULL != this->_ui16p_channel[0]) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Toshihiro Shimizu |
890ddd |
pri_funct_msg_ttvr( "thinnest_ui16_image::mem_free()" );
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
free( this->_ui16p_channel[0]);
|
|
Toshihiro Shimizu |
890ddd |
this->_ui16p_channel[0] = NULL;
|
|
Toshihiro Shimizu |
890ddd |
this->_ui16p_channel[1] = NULL;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Shinya Kitaoka |
120a6e |
if (NULL != this->memory_free_this_) {
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::mem_free() <%x>",
|
|
Shinya Kitaoka |
120a6e |
this->memory_free_this_);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
free(this->memory_free_this_);
|
|
Shinya Kitaoka |
120a6e |
this->memory_free_this_ = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[0] = NULL;
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[1] = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int thinnest_ui16_image::mem_alloc(void) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::mem_alloc()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr(
|
|
Shinya Kitaoka |
120a6e |
"alloc ui16_image memory (%d+%d) x (%d+%d) x %d x %d bytes",
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xs * this->_i32_xd, 2, this->_i32_ys * this->_i32_yd, 2, 2,
|
|
Shinya Kitaoka |
120a6e |
sizeof(uint16_t));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->memory_free_this_ = this->_ui16p_channel[0] =
|
|
Shinya Kitaoka |
120a6e |
(uint16_t *)calloc((this->_i32_xs * this->_i32_xd + 2) *
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_ys * this->_i32_yd + 2) * 2,
|
|
Shinya Kitaoka |
120a6e |
sizeof(uint16_t));
|
|
otakuto |
c39a2a |
if (this->_i_pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr("thinnest_ui16_image::mem_alloc() memory <%x>",
|
|
Shinya Kitaoka |
120a6e |
this->memory_free_this_);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL == this->_ui16p_channel[0]) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_err_bttvr("Error : calloc(-) returns NULL.");
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[1] =
|
|
Shinya Kitaoka |
120a6e |
this->_ui16p_channel[0] +
|
|
Shinya Kitaoka |
120a6e |
(this->_i32_xs * this->_i32_xd + 2) * (this->_i32_ys * this->_i32_yd + 2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h> /* assert() */</assert.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::_one_side_thinner(void) {
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_y1, *ui16p_src_y2, *ui16p_src_y3, *ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
int32_t yy, i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
/******if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr( "thinnest_ui16_image::_one_side_thinner()" );
|
|
Shinya Kitaoka |
120a6e |
}******/
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_start( this->_i32_ys ); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y1 = this->get_ui16p_src_channel() + this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y2 = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y3 = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt = this->get_ui16p_tgt_channel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_delete_count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_run(yy); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_delete_count += this->_one_side_thinner_scanline(
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y1, ui16p_src_y2, ui16p_src_y3, ui16p_tgt);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y3 = ui16p_src_y2;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y2 = ui16p_src_y1;
|
|
Shinya Kitaoka |
120a6e |
if ((yy + 1) < (this->_i32_ys)) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y1 += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_y1 = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt += this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_end(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_swap_channel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::_one_side_thinner_scanline(uint16_t *ui16p_src_y1,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_y2,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_y3,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_tgt) {
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x1a, *ui16p_src_x1b, *ui16p_src_x1c, *ui16p_src_x2a,
|
|
Shinya Kitaoka |
120a6e |
*ui16p_src_x2b, *ui16p_src_x2c, *ui16p_src_x3a, *ui16p_src_x3b,
|
|
Shinya Kitaoka |
120a6e |
*ui16p_src_x3c, ui16_src_x2c_before, ui16_src_x2b_before;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1c = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2c = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3b = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3c = NULL;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_src_y1) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1a = ui16p_src_y1 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1b = ui16p_src_y1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_src_y2) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2a = ui16p_src_y2 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2b = ui16p_src_y2;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != ui16p_src_y3) {
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3a = ui16p_src_y3 + 1;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3b = ui16p_src_y3;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
ui16_src_x2c_before = 0;
|
|
Shinya Kitaoka |
120a6e |
ui16_src_x2b_before = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_delete_count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != ui16p_src_x2b);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16_src_x2b_before = (*ui16p_src_x2b);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ピクセル位置が一番左はじ、あるいは、
|
|
Shinya Kitaoka |
120a6e |
前のピクセルがゼロ値(黒)で、
|
|
Shinya Kitaoka |
120a6e |
カレントピクセルがゼロ以外(白)のとき
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
if (((NULL == ui16p_src_x2c) || (0 == ui16_src_x2c_before)) &&
|
|
Shinya Kitaoka |
120a6e |
(0 < (*ui16p_src_x2b))) {
|
|
Shinya Kitaoka |
120a6e |
i32_delete_count += this->_one_side_thinner_pixel(
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1a, ui16p_src_x1b, ui16p_src_x1c, ui16p_src_x2a,
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2b, ui16p_src_x2c, ui16p_src_x3a, ui16p_src_x3b,
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3c, ui16p_tgt);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = *ui16p_src_x2b;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16_src_x2c_before = ui16_src_x2b_before;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1c = ui16p_src_x1b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1b = ui16p_src_x1a;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2c = ui16p_src_x2b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2b = ui16p_src_x2a;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3c = ui16p_src_x3b;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3b = ui16p_src_x3a;
|
|
Shinya Kitaoka |
120a6e |
if ((xx + 1) < (this->_i32_xs)) {
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x1a)) ++ui16p_src_x1a;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x2a)) ++ui16p_src_x2a;
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x3a)) ++ui16p_src_x3a;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x1a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x2a = NULL;
|
|
Shinya Kitaoka |
120a6e |
ui16p_src_x3a = NULL;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
++ui16p_tgt;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int32_t thinnest_ui16_image::_one_side_thinner_pixel(
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x1a, uint16_t *ui16p_src_x1b, uint16_t *ui16p_src_x1c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x2a, uint16_t *ui16p_src_x2b, uint16_t *ui16p_src_x2c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src_x3a, uint16_t *ui16p_src_x3b, uint16_t *ui16p_src_x3c,
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_tgt) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
long l_off_count, l_white_count;
|
|
otakuto |
c39a2a |
bool i_sw, i_sw2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(NULL != ui16p_src_x2b);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_delete_count = 0;
|
|
Shinya Kitaoka |
120a6e |
l_off_count = 0L;
|
|
Shinya Kitaoka |
120a6e |
l_white_count = 0L;
|
|
otakuto |
c39a2a |
i_sw = i_sw2 = false;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x1a)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x1a);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x1b)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x1b);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x1c)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x1c);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x2c)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x2c);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x3c)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x3c);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x3b)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x3b);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x3a)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x3a);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x2a)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x2a);
|
|
otakuto |
c39a2a |
if (i_sw) ++l_white_count;
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (NULL != (ui16p_src_x1a)) {
|
|
otakuto |
c39a2a |
i_sw = 0 < (*ui16p_src_x1a);
|
|
otakuto |
c39a2a |
if (!i_sw && i_sw2) ++l_off_count;
|
|
Shinya Kitaoka |
120a6e |
i_sw2 = i_sw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (l_white_count <= 0L) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
++i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else if ((1L == l_off_count) && (3 <= l_white_count)) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = 0;
|
|
Shinya Kitaoka |
120a6e |
++i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt = *ui16p_src_x2b;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return i32_delete_count;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "thinnest_ui16_image.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void thinnest_ui16_image::_rot90_by_clockwork(void) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_tmp;
|
|
Shinya Kitaoka |
120a6e |
int32_t xx, yy;
|
|
Shinya Kitaoka |
120a6e |
uint16_t *ui16p_src, *ui16p_tgt_y, *ui16p_tgt_x;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
/******if (this->_i_mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_msg_ttvr( "thinnest_ui16_image::_rot90_by_clockwork()" );
|
|
Shinya Kitaoka |
120a6e |
}******/
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_start( this->_i32_ys ); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_src = this->get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt_y = this->get_ui16p_tgt_channel() + (this->_i32_ys - 1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (yy = 0L; yy < this->_i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_run(yy); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt_x = ui16p_tgt_y;
|
|
Shinya Kitaoka |
120a6e |
for (xx = 0L; xx < this->_i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
*ui16p_tgt_x = *ui16p_src;
|
|
Shinya Kitaoka |
120a6e |
++ui16p_src;
|
|
Shinya Kitaoka |
120a6e |
ui16p_tgt_x += this->_i32_ys;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
// if (this->_i_cv_sw) { pri_funct_cv_end(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_tmp = this->_i32_xs;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xs = this->_i32_ys;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_ys = i32_tmp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_tmp = this->_i32_xd;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_xd = this->_i32_yd;
|
|
Shinya Kitaoka |
120a6e |
this->_i32_yd = i32_tmp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
this->_swap_channel();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <stdexcept></stdexcept>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "brush_curve_blur.h" "igs_line_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_curve_point_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
double *dp_pixel, int xp, int yp, const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, T *image_top
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
for (int zz = 0; zz < channels; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
image_top[yp * channels * width + xp * channels + zz] =
|
|
Shinya Kitaoka |
120a6e |
static_cast<t>(dp_pixel[zz]);</t>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
int xp, int yp
|
|
Toshihiro Shimizu |
890ddd |
--> ピクセル位置
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_curve_point_put_image_(
|
|
Shinya Kitaoka |
120a6e |
brush_curve_blur &cl_brush_curve_blur, int xp, int yp,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, void *out
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
if ((xp < 0) && (width <= xp) && (yp < 0) && (height <= yp)) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : igs::line_blur::_brush_curve_point_put_image(-)");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (16 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_point_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_pixel(), xp, yp, height, width, channels,
|
|
Shinya Kitaoka |
120a6e |
static_cast<unsigned *="" short="">(out));</unsigned>
|
|
Shinya Kitaoka |
120a6e |
} else if (8 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_point_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_pixel(), xp, yp, height, width, channels,
|
|
Shinya Kitaoka |
120a6e |
static_cast<unsigned *="" char="">(out));</unsigned>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "brush_curve_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_curve_line_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
const T *image_top, int height, int width, int channels, int i32_blur_count,
|
|
Shinya Kitaoka |
120a6e |
double *xp_array, double *yp_array, double *linepixels_array, double xp,
|
|
Shinya Kitaoka |
120a6e |
double yp) {
|
|
Shinya Kitaoka |
120a6e |
for (int ii = 0; ii < i32_blur_count; ++ii) {
|
|
Shinya Kitaoka |
120a6e |
const int xx = (int)(xp_array[ii] + xp + 0.5);
|
|
Shinya Kitaoka |
120a6e |
const int yy = (int)(yp_array[ii] + yp + 0.5);
|
|
Shinya Kitaoka |
120a6e |
if ((0 <= xx) && (xx < width) && (0 <= yy) && (yy < height)) {
|
|
Shinya Kitaoka |
120a6e |
for (int zz = 0; zz < channels; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
linepixels_array[ii * CHANNEL_COUNT + zz] =
|
|
Shinya Kitaoka |
120a6e |
(double)(image_top[yy * channels * width + xx * channels + zz]) +
|
|
Shinya Kitaoka |
120a6e |
0.999999;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
for (int zz = 0; zz < channels; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
linepixels_array[ii * CHANNEL_COUNT + zz] = -1.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
this->cl_brush_curve_blur.get_dp_xp()
|
|
Toshihiro Shimizu |
890ddd |
this->cl_brush_curve_blur.get_dp_yp()
|
|
Toshihiro Shimizu |
890ddd |
double xp, double yp
|
|
Toshihiro Shimizu |
890ddd |
--> ピクセルの真中が原点
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_curve_line_get_image_(
|
|
Shinya Kitaoka |
120a6e |
brush_curve_blur &cl_brush_curve_blur, const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, double xp, double yp) {
|
|
Shinya Kitaoka |
120a6e |
if (16 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_line_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
static_cast<const *="" short="" unsigned="">(in), height, width, channels,</const>
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_i32_count(), cl_brush_curve_blur.get_dp_xp(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_yp(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_linepixels(), xp, yp);
|
|
Shinya Kitaoka |
120a6e |
} else if (8 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_line_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
static_cast<const *="" char="" unsigned="">(in), height, width, channels,</const>
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_i32_count(), cl_brush_curve_blur.get_dp_xp(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_yp(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_linepixels(), xp, yp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <iostream></iostream>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h> /* memcpy() */</string.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h" "brush_curve_blur.h" "pixel_select_curve_blur.h" "pixel_line_root.h" "igs_line_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int igs_line_blur_brush_curve_blur_subpixel_(
|
|
Shinya Kitaoka |
120a6e |
brush_curve_blur &cl_brush_curve_blur,
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_root &cl_pixel_select_curve_blur_root,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root &cl_pixel_line_root
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, int32_t xx, int32_t yy) {
|
|
Shinya Kitaoka |
120a6e |
int32_t i32_subpixel, xsub, ysub;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
i32_subpixel = cl_brush_curve_blur.get_i32_subpixel_divide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (ysub = 0; ysub < i32_subpixel; ++ysub) {
|
|
Shinya Kitaoka |
120a6e |
for (xsub = 0; xsub < i32_subpixel; ++xsub) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root.exec(
|
|
Shinya Kitaoka |
120a6e |
(double)xx + (double)xsub / i32_subpixel - 0.5,
|
|
Shinya Kitaoka |
120a6e |
(double)yy + (double)ysub / i32_subpixel - 0.5, &(cl_pixel_line_root),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_i32_count(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_d_effect_area_radius());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (cl_pixel_select_curve_blur_root.get_i32_count() <= 0) {
|
|
Shinya Kitaoka |
120a6e |
return NG;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root.get_line(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_i32_count(), cl_brush_curve_blur.get_dp_xp(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.get_dp_yp());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_line_get_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur, in, height, width, channels, bits,
|
|
Shinya Kitaoka |
120a6e |
(double)xx + (double)xsub / i32_subpixel - 0.5,
|
|
Shinya Kitaoka |
120a6e |
(double)yy + (double)ysub / i32_subpixel - 0.5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_subpixel_value(xsub, ysub);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int igs_line_blur_brush_curve_blur_all_(
|
|
otakuto |
c39a2a |
bool mv_sw, bool pv_sw, bool cv_sw,
|
|
otakuto |
c39a2a |
brush_curve_blur &cl_brush_curve_blur,
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_root &cl_pixel_select_curve_blur_root,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root &cl_pixel_line_root
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, void *out
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << "igs::line_blur::_brush_curve_blur_all()" << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << " curve blur points count is " << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_curve_blur.get_i32_count() << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< " power is " << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_curve_blur.get_d_power() << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< " subpixel divide is " << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_curve_blur.get_i32_subpixel_divide() << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< " clip area for speedup is " << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_curve_blur.get_d_effect_area_radius() << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_brush_curve_blur.mem_alloc()) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_brush_curve_blur.mem_alloc() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.init_ratio_array();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 画像をinからoutへコピーしておく */
|
|
Shinya Kitaoka |
120a6e |
(void)memcpy(out, in, height * width * channels * ((16 == bits) ? 2 : 1));
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(height);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int yy = 0; yy < height; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int xx = 0; xx < width; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
if (OK == igs_line_blur_brush_curve_blur_subpixel_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur, cl_pixel_select_curve_blur_root,
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root, in, height, width, channels, bits, xx,
|
|
Shinya Kitaoka |
120a6e |
yy)) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_pixel_value();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 結果をピクセルへ置く
|
|
Shinya Kitaoka |
120a6e |
(取ったものと別の画像におくこと) */
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_point_put_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur, xx, yy, height, width, channels, bits, out);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return OK;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* floor() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "brush_smudge_circle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
T *in, int height, int width, int channels, double x1, double y1, double x2,
|
|
Shinya Kitaoka |
120a6e |
double y2, double d_subsize, double *dp_image) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int x1p = (int)floor(x1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int x2p = (int)floor(x2 - d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int y1p = (int)floor(y1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int y2p = (int)floor(y2 - d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int yy = y1p; yy <= y2p; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (int xx = x1p; xx <= x2p; ++xx, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
if ((0 <= xx) && (xx < width) && (0 <= yy) && (yy < height)) {
|
|
Shinya Kitaoka |
120a6e |
for (int zz = 0; zz < 4; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
if (zz < channels) {
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz] =
|
|
Shinya Kitaoka |
120a6e |
(double)(in[yy * channels * width + xx * channels + zz]) +
|
|
Shinya Kitaoka |
120a6e |
0.999999;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
dp_image[4] = 1.0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
dp_image[4] = 0.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_get_image_(
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle &cl_brush_smudge_circle, const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, double d_xp, double d_yp) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double x1, y1, x2, y2;
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(d_xp, d_yp, &x1, &y1, &x2, &y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (16 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
static_cast<const *="" short="" unsigned="">(in), height, width, channels, x1,</const>
|
|
Shinya Kitaoka |
120a6e |
y1, x2, y2, 1.0 / cl_brush_smudge_circle.get_i32_subpixel_divide(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_pixel_image());
|
|
Shinya Kitaoka |
120a6e |
} else if (8 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_template_(
|
|
Shinya Kitaoka |
120a6e |
static_cast<const *="" char="" unsigned="">(in), height, width, channels, x1, y1,</const>
|
|
Shinya Kitaoka |
120a6e |
x2, y2, 1.0 / cl_brush_smudge_circle.get_i32_subpixel_divide(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_pixel_image());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h> /* floor() */</math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "brush_smudge_circle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class t=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
double x1, double y1, double x2, double y2, double d_subsize,
|
|
Shinya Kitaoka |
120a6e |
double *dp_image, int height, int width, int channels, T *out) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int x1p = (int)floor(x1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int x2p = (int)floor(x2 - d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int y1p = (int)floor(y1 + d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
int y2p = (int)floor(y2 - d_subsize / 2.0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int yy = y1p; yy <= y2p; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
for (int xx = x1p; xx <= x2p; ++xx, dp_image += 5) {
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 < dp_image[4]) && (0 <= xx) && (xx < width) && (0 <= yy) &&
|
|
Shinya Kitaoka |
120a6e |
(yy < height)) {
|
|
Shinya Kitaoka |
120a6e |
for (int zz = 0; zz < channels; ++zz) {
|
|
Shinya Kitaoka |
120a6e |
out[yy * channels * width + xx * channels + zz] = static_cast<t>(</t>
|
|
Shinya Kitaoka |
120a6e |
(double)out[yy * channels * width + xx * channels + zz] *
|
|
Shinya Kitaoka |
120a6e |
(1.0 - dp_image[4]) +
|
|
Shinya Kitaoka |
120a6e |
dp_image[zz]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_put_image_(
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle &cl_brush_smudge_circle, double d_xp, double d_yp,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, void *out
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double x1, y1, x2, y2;
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(d_xp, d_yp, &x1, &y1, &x2, &y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (16 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
x1, y1, x2, y2, 1.0 / cl_brush_smudge_circle.get_i32_subpixel_divide(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_pixel_image(), height, width, channels,
|
|
Shinya Kitaoka |
120a6e |
static_cast<unsigned *="" short="">(out));</unsigned>
|
|
Shinya Kitaoka |
120a6e |
} else if (8 == bits) {
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_put_image_template_(
|
|
Shinya Kitaoka |
120a6e |
x1, y1, x2, y2, 1.0 / cl_brush_smudge_circle.get_i32_subpixel_divide(),
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_pixel_image(), height, width, channels,
|
|
Shinya Kitaoka |
120a6e |
static_cast<unsigned *="" char="">(out));</unsigned>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#include <stdexcept></stdexcept>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "brush_smudge_circle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_line_(
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle &cl_brush_smudge_circle, const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, void *out
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line) {
|
|
Shinya Kitaoka |
120a6e |
pixel_point_node *clp_one_expand, *clp_another_expand, *clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
int32_t ii;
|
|
Shinya Kitaoka |
120a6e |
double d_x1, d_y1, d_x2, d_y2;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_one_expand = clp_line->get_clp_link_one_expand();
|
|
Shinya Kitaoka |
120a6e |
clp_another_expand = clp_line->get_clp_link_another_expand();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_brush_circle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_line->get_clp_link_middle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, in, height, width, channels, bits,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), &d_x1, &d_y1,
|
|
Shinya Kitaoka |
120a6e |
&d_x2, &d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_subpixel_from_pixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.copy_to_brush_from_image();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_crnt = clp_crnt->get_clp_next_point(), ii = 0; NULL != clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_crnt->get_clp_next_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_line->get_i32_point_count() <= ii) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error("Error : over clp_line->get_i32_point_count()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), &d_x1, &d_y1,
|
|
Shinya Kitaoka |
120a6e |
&d_x2, &d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 <= d_x2) && (d_x1 < width) && (0.0 <= d_y2) && (d_y1 < height)) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, in, height, width, channels, bits,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_subpixel_from_pixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.exec();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_pixel_from_subpixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_put_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), height, width, channels, bits, out);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// if (clp_another_expand == clp_crnt) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_line->get_clp_link_middle();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, in, height, width, channels, bits,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), &d_x1, &d_y1,
|
|
Shinya Kitaoka |
120a6e |
&d_x2, &d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_subpixel_from_pixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.copy_to_brush_from_image();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (clp_crnt = clp_crnt->get_clp_previous_point(), ii = 0; NULL != clp_crnt;
|
|
Shinya Kitaoka |
120a6e |
clp_crnt = clp_crnt->get_clp_previous_point(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (clp_line->get_i32_point_count() <= ii) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : over clp_line->get_i32_point_count() going front");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.get_dp_area(clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), &d_x1, &d_y1,
|
|
Shinya Kitaoka |
120a6e |
&d_x2, &d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if ((0.0 <= d_x2) && (d_x1 < width) && (0.0 <= d_y2) && (d_y1 < height)) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_get_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, in, height, width, channels, bits,
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_xp_tgt(), clp_crnt->get_d_yp_tgt());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_subpixel_from_pixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.exec();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.to_pixel_from_subpixel(d_x1, d_y1, d_x2, d_y2);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_put_image_(
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle, clp_crnt->get_d_xp_tgt(),
|
|
Shinya Kitaoka |
120a6e |
clp_crnt->get_d_yp_tgt(), height, width, channels, bits, out);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// if (clp_one_expand == clp_crnt) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <iostream></iostream>
|
|
Toshihiro Shimizu |
890ddd |
#include <string.h> /* memcpy() */</string.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void igs_line_blur_brush_smudge_all_(
|
|
otakuto |
c39a2a |
bool mv_sw, bool pv_sw, bool cv_sw,
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle &cl_brush_smudge_circle,
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root &cl_pixel_line_root, const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits, void *out
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << "igs::line_expand::_brush_smudge_all()" << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (pv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << " smudge ratio " << cl_brush_smudge_circle.get_d_ratio()
|
|
Shinya Kitaoka |
120a6e |
<< std::endl
|
|
Shinya Kitaoka |
120a6e |
<< " smudge brush size by pixel "
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_smudge_circle.get_i32_size_by_pixel() << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< " smudge subpixel divide "
|
|
Shinya Kitaoka |
120a6e |
<< cl_brush_smudge_circle.get_i32_subpixel_divide() << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_brush_smudge_circle.mem_alloc()) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_brush_smudge_circle.mem_alloc() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 画像をinからoutへコピーしておく */
|
|
Shinya Kitaoka |
120a6e |
(void)memcpy(out, in, height * width * channels * ((16 == bits) ? 2 : 1));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(cl_pixel_line_root.get_i32_count());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
pixel_line_node *clp_line =
|
|
Shinya Kitaoka |
120a6e |
(pixel_line_node *)cl_pixel_line_root.get_clp_first();
|
|
Shinya Kitaoka |
120a6e |
for (int ii = 0; NULL != clp_line;
|
|
Shinya Kitaoka |
120a6e |
clp_line = (pixel_line_node *)clp_line->get_clp_next(), ++ii) {
|
|
Shinya Kitaoka |
120a6e |
if (cl_pixel_line_root.get_i32_count() <= ii) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : over cl_pixel_line_root.get_i32_count()");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(ii);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_line_(cl_brush_smudge_circle, in, height, width,
|
|
Shinya Kitaoka |
120a6e |
channels, bits, out, clp_line);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <iostream></iostream>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdexcept></stdexcept>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "pri.h"
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
void igs_line_blur_image_get_(const bool mv_sw, const bool cv_sw,
|
|
Shinya Kitaoka |
120a6e |
const long reference_channel,
|
|
Shinya Kitaoka |
120a6e |
thinnest_ui16_image &cl_thinnest_ui16_image
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << "igs_line_blur_image_get_()" << std::endl
|
|
Shinya Kitaoka |
120a6e |
<< "com : reference channel " << reference_channel << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i32_xs = cl_thinnest_ui16_image.get_i32_xs();
|
|
Shinya Kitaoka |
120a6e |
int i32_ys = cl_thinnest_ui16_image.get_i32_ys();
|
|
Shinya Kitaoka |
120a6e |
unsigned short *out_incr = cl_thinnest_ui16_image.get_ui16p_src_channel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_start(i32_ys);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (8 == bits) {
|
|
Shinya Kitaoka |
120a6e |
const unsigned char *in_incr = static_cast<const *="" char="" unsigned="">(in);</const>
|
|
Shinya Kitaoka |
120a6e |
in_incr += reference_channel;
|
|
Shinya Kitaoka |
120a6e |
for (int yy = 0; yy < i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int xx = 0; xx < i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
*out_incr =
|
|
Shinya Kitaoka |
120a6e |
(((unsigned short)(*in_incr)) << 8) + (unsigned short)(*in_incr);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
in_incr += channels;
|
|
Shinya Kitaoka |
120a6e |
++out_incr;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else if (16 == bits) {
|
|
Shinya Kitaoka |
120a6e |
const unsigned short *in_incr = static_cast<const *="" short="" unsigned="">(in);</const>
|
|
Shinya Kitaoka |
120a6e |
in_incr += reference_channel;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int yy = 0; yy < i32_ys; ++yy) {
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_run(yy);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int xx = 0; xx < i32_xs; ++xx) {
|
|
Shinya Kitaoka |
120a6e |
*out_incr = *in_incr;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
in_incr += channels;
|
|
Shinya Kitaoka |
120a6e |
++out_incr;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error("Error : bits is not 8 or 16");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (cv_sw) {
|
|
Shinya Kitaoka |
120a6e |
pri_funct_cv_end();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <iostream></iostream>
|
|
Toshihiro Shimizu |
890ddd |
#include <stdexcept></stdexcept>
|
|
Shinya Kitaoka |
120a6e |
#include "igs_line_blur.h" // "thinnest_ui16_image.h" "pixel_point_root.h" "pixel_line_root.h" "brush_curve_blur.h" "brush_smudge_circle.h" "pixel_select_same_way.h" "pixel_select_curve_blur.h" "igs_line_blur.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void igs::line_blur::convert(
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const void *in
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
void *out
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int height
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int width
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int channels, const int bits
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int b_blur_count
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const double b_blur_power
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int b_subpixel
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int b_blur_near_ref
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int b_blur_near_len
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int b_smudge_thick
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const double b_smudge_remain
|
|
Shinya Kitaoka |
120a6e |
/* min=0.0 def=0.85 incr=0.001 max=1.0*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int v_smooth_retry
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int v_near_ref
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int v_near_len
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
,
|
|
otakuto |
c39a2a |
const bool mv_sw
|
|
Shinya Kitaoka |
120a6e |
,
|
|
otakuto |
c39a2a |
const bool pv_sw
|
|
Shinya Kitaoka |
120a6e |
,
|
|
otakuto |
c39a2a |
const bool cv_sw
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const long reference_channel
|
|
Shinya Kitaoka |
120a6e |
,
|
|
otakuto |
c39a2a |
const bool debug_save_sw
|
|
Shinya Kitaoka |
120a6e |
,
|
|
Shinya Kitaoka |
120a6e |
const int brush_action
|
|
Shinya Kitaoka |
120a6e |
) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
thinnest_ui16_image cl_thinnest_ui16_image;
|
|
Shinya Kitaoka |
120a6e |
pixel_point_root cl_pixel_point_root;
|
|
Shinya Kitaoka |
120a6e |
pixel_line_root cl_pixel_line_root;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_same_way_root cl_pixel_select_same_way_root;
|
|
Shinya Kitaoka |
120a6e |
pixel_select_curve_blur_root cl_pixel_select_curve_blur_root;
|
|
Shinya Kitaoka |
120a6e |
brush_smudge_circle cl_brush_smudge_circle;
|
|
Shinya Kitaoka |
120a6e |
brush_curve_blur cl_brush_curve_blur;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.set_i_mv_sw(mv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_point_root.set_i_mv_sw(mv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.set_i_mv_sw(mv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_i_mv_sw(mv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_i_mv_sw(mv_sw);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.set_i_pv_sw(pv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_point_root.set_i_pv_sw(pv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.set_i_pv_sw(pv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_i_pv_sw(pv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_i_pv_sw(pv_sw);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.set_i_cv_sw(cv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_point_root.set_i_cv_sw(cv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.set_i_cv_sw(cv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_i_cv_sw(cv_sw);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_i_cv_sw(cv_sw);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (mv_sw) {
|
|
Shinya Kitaoka |
120a6e |
std::cout << "igs::line_blur::convert()" << std::endl;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.set_i32_xs(width);
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.set_i32_ys(height);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 0: $type : Wheel (min=0, default=0, increment=1, max=1) */
|
|
Shinya Kitaoka |
120a6e |
/****** if (0 == b_action_mode) {
|
|
Shinya Kitaoka |
120a6e |
this->set_e_brush_smudge_action();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
this->set_e_brush_curve_blur_action();
|
|
otakuto |
c39a2a |
cl_pixel_line_root.set_i_same_way_exec_sw(false);
|
|
Shinya Kitaoka |
120a6e |
}******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 1: $b_blur_count :Wheel(min=1, default=51, increment=1, max=100) */
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_i32_count(b_blur_count);
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_d_effect_area_radius((double)(b_blur_count / 2));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 2: $b_blur_power :Wheel(min=0.1,default=1,increment=0.1,max=hh0) */
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_d_power(b_blur_power);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 3. $b_subpixel : Wheel (min=1, default=1, increment=1, max=8) */
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.set_i32_subpixel_divide(b_subpixel);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 4: $b_blur_near_ref:Wheel(min=1, default=5, increment=1, max=100) */
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root.set_i32_count_max(b_blur_near_ref);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 5: $b_blur_near_len:Wheel(min=1, default=160, increment=1, max=1000) */
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root.set_d_length_max(b_blur_near_len);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 6: $b_smudge_thick :Wheel(min=1, default=7, increment=1, max=100) */
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_i32_size_by_pixel(b_smudge_thick);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 7: $b_smudge_remain:Wheel(min=0.0,default=0.85,increment=0.001,max=1.0)*/
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.set_d_ratio(b_smudge_remain);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 8: $v_smooth_retry :Wheel(min=0, default=100, increment=1, max=1000) */
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.set_i32_smooth_retry(v_smooth_retry);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* 9: $v_near_ref :Wheel(min=0, default=4, increment=1, max=100) */
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_same_way_root.set_i32_count_max(v_near_ref);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*10: $v_near_len :Wheel(min=2, default=160, increment=1, max=1000) */
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_same_way_root.set_d_length_max(v_near_len);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_thinnest_ui16_image.mem_alloc()) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_thinnest_ui16_image.mem_alloc() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_image_get_(mv_sw, cv_sw, reference_channel,
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image, in, height, width, channels,
|
|
Shinya Kitaoka |
120a6e |
bits);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/****** 細線化処理 start ******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.exec01_fill_noise_pixel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.exec02_scale_add_edge_pixel();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.exec03_scale_liner();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.exec04_bw();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_thinnest_ui16_image.exec05_thin()) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_thinnest_ui16_image.exec05_thin() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/****** 細線化処理 end ******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/****** ベクトルリスト処理 start ******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_point_root.alloc_mem_and_list_node(
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.get_i32_xs(),
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.get_i32_ys(),
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.get_ui16p_src_channel())) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_point_root.alloc_mem_and_list_node() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.exec01020304(&(cl_pixel_point_root))) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.exec01020304() returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
otakuto |
c39a2a |
if (debug_save_sw) {
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.save_lines("tmp08_jaggy_lines.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_lines(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.save_one_point("tmp09_one_point.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_one_point(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_another_point("tmp10_another_point.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_another_point(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_not_include(&(cl_pixel_point_root),
|
|
Shinya Kitaoka |
120a6e |
"tmp11_not_include.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_not_include(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec05_set_middle();
|
|
otakuto |
c39a2a |
if (debug_save_sw) {
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.save_middle_point("tmp12_middle_point.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_middle_point(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec06_int2double_body();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec07_smooth_body();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.exec08_expand_lines(&(cl_pixel_point_root))) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.exec08_expand_lines(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (debug_save_sw) {
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_expand_vector("tmp13_expand_vector.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_expand_vector(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec09_same_way_expand(&(cl_pixel_select_same_way_root));
|
|
otakuto |
c39a2a |
if (debug_save_sw) {
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_expand_vector("tmp14_same_way_vector.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_expand_vector(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec10_smooth_expand();
|
|
Shinya Kitaoka |
120a6e |
|
|
otakuto |
c39a2a |
if (debug_save_sw) {
|
|
Shinya Kitaoka |
120a6e |
if (OK != cl_pixel_line_root.save_expand_lines("tmp15_expand_lines.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_expand_lines(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_one_expand_point(
|
|
Shinya Kitaoka |
120a6e |
"tmp16_one_expand_point.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_one_expand_point(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (OK !=
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.save_another_expand_point(
|
|
Shinya Kitaoka |
120a6e |
"tmp17_another_expand_point.txt")) {
|
|
Shinya Kitaoka |
120a6e |
throw std::domain_error(
|
|
Shinya Kitaoka |
120a6e |
"Error : cl_pixel_line_root.save_another_expand_point(-) returns NG");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.exec11_set_bbox();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/****** ベクトルリスト処理 end ******/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (0 == brush_action) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_curve_blur_all_(
|
|
Shinya Kitaoka |
120a6e |
mv_sw, pv_sw, cv_sw, cl_brush_curve_blur,
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root, cl_pixel_line_root, in, height, width,
|
|
Shinya Kitaoka |
120a6e |
channels, bits, out);
|
|
Shinya Kitaoka |
120a6e |
} else if (1 == brush_action) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
igs_line_blur_brush_smudge_all_(mv_sw, pv_sw, cv_sw, cl_brush_smudge_circle,
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root, in, height, width,
|
|
Shinya Kitaoka |
120a6e |
channels, bits, out);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_smudge_circle.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_brush_curve_blur.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_curve_blur_root.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_select_same_way_root.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_line_root.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_pixel_point_root.mem_free();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
cl_thinnest_ui16_image.mem_free();
|
|
Toshihiro Shimizu |
890ddd |
}
|