|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
d869b5 |
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
|
Toshihiro Shimizu |
890ddd |
#define _CRT_SECURE_NO_DEPRECATE 1
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// STColSelPic.h: interface for the CSTColSelPic class.
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
//////////////////////////////////////////////////////////////////////
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if !defined(AFX_STCOLSELPIC_H__80D708B0_FCA2_11D5_B949_0040F674BE6A__INCLUDED_)
|
|
Toshihiro Shimizu |
890ddd |
#define AFX_STCOLSELPIC_H__80D708B0_FCA2_11D5_B949_0040F674BE6A__INCLUDED_
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
e280ae |
#ifdef _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(disable : 4996)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include <streambuf></streambuf>
|
|
Toshihiro Shimizu |
890ddd |
#include <vector></vector>
|
|
Shinya Kitaoka |
6a4e01 |
#include <memory></memory>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h></math.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <memory.h></memory.h>
|
|
Toshihiro Shimizu |
890ddd |
#include "YOMBInputParam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "STPic.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "SDef.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "CIL.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "SError.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class p=""></class>
|
|
Shinya Kitaoka |
d1f6c4 |
class CSTColSelPic final : public CSTPic {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
std::shared_ptr<uchar> m_sel;</uchar>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
CSTColSelPic() : CSTPic() {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~CSTColSelPic(){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void nullSel() { m_sel.reset(); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void initSel() // throw(SMemAllocError)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
nullSel();
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_lX > 0 && CSTPic ::m_lY > 0) {
|
|
Shinya Kitaoka |
120a6e |
m_sel.reset(new UCHAR[CSTPic::m_lX * CSTPic ::m_lY],
|
|
Shinya Kitaoka |
120a6e |
std::default_delete<uchar[]>());</uchar[]>
|
|
Shinya Kitaoka |
120a6e |
if (!m_sel) throw SMemAllocError(" in initColorSelection");
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
char s[200];
|
|
Rozhuk Ivan |
823a31 |
snprintf(s, sizeof(s), " in initColorSelection lXY=(%d,%d)\n",
|
|
Rozhuk Ivan |
823a31 |
CSTPic::m_lX, CSTPic ::m_lY);
|
|
Shinya Kitaoka |
120a6e |
throw SMemAllocError(s);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void copySel(const UCHAR *sel) {
|
|
Shinya Kitaoka |
120a6e |
memcpy(m_sel.get(), sel, CSTPic::m_lX * CSTPic ::m_lY * sizeof(UCHAR));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void copySel(const UCHAR sel) {
|
|
Shinya Kitaoka |
120a6e |
memset(m_sel.get(), sel, CSTPic::m_lX * CSTPic ::m_lY * sizeof(UCHAR));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
CSTColSelPic(const CSTColSelPic &csp) /*throw(SMemAllocError) */
|
|
Shinya Kitaoka |
120a6e |
: CSTPic(csp) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
const CSTColSelPic &operator=(
|
|
Shinya Kitaoka |
120a6e |
const CSTColSelPic &sp) // throw(SMemAllocError)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
const CSTPic *spp;
|
|
Shinya Kitaoka |
120a6e |
CSTPic *dpp;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
try {
|
|
Shinya Kitaoka |
120a6e |
CSTPic::null();
|
|
Shinya Kitaoka |
120a6e |
spp = static_cast<const cstpic<p=""> *>(&sp);</const>
|
|
Shinya Kitaoka |
120a6e |
dpp = static_cast<cstpic<p> *>(this);</cstpic<p>
|
|
Shinya Kitaoka |
120a6e |
*dpp = *spp;
|
|
Shinya Kitaoka |
120a6e |
if (sp.m_sel && CSTPic::m_lX > 0 && CSTPic ::m_lY > 0) {
|
|
Shinya Kitaoka |
120a6e |
initSel();
|
|
Shinya Kitaoka |
120a6e |
copySel(sp.m_sel.get());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} catch (SMemAllocError) {
|
|
Shinya Kitaoka |
120a6e |
throw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return (*this);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int isInCIL(USHORT c, const COLOR_INDEX_LIST &cil) {
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < cil.nb; i++)
|
|
Shinya Kitaoka |
120a6e |
if (cil.ci[i] == c) return i;
|
|
Shinya Kitaoka |
120a6e |
return -1;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionCMAP32(const COLOR_INDEX_LIST &ink,
|
|
Shinya Kitaoka |
120a6e |
const COLOR_INDEX_LIST &paint) {
|
|
Shinya Kitaoka |
120a6e |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
P *pic = CSTPic::m_pic;
|
|
Shinya Kitaoka |
120a6e |
int xy = 0, nbSel = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < CSTPic::m_lY; y++)
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < CSTPic::m_lX; x++, xy++, pSel++, pic++) {
|
|
Shinya Kitaoka |
120a6e |
int xyRas = y * CSTPic::m_ras->wrap + x;
|
|
Shinya Kitaoka |
120a6e |
UD44_CMAPINDEX32 ci32 =
|
|
Shinya Kitaoka |
120a6e |
*((UD44_CMAPINDEX32 *)(CSTPic::m_ras->buffer) + xyRas);
|
|
Shinya Kitaoka |
120a6e |
if ((ci32 & 0x000000ff) == 0xff) {
|
|
Shinya Kitaoka |
120a6e |
// Paint color
|
|
Shinya Kitaoka |
120a6e |
int p = isInCIL((int)((ci32 >> 8) & 0x00000fff), paint);
|
|
Shinya Kitaoka |
120a6e |
if (p >= 0) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255 - p;
|
|
Shinya Kitaoka |
120a6e |
nbSel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
} else if ((ci32 & 0x000000ff) == 0x0) {
|
|
Shinya Kitaoka |
120a6e |
// Ink color
|
|
Shinya Kitaoka |
120a6e |
int p = isInCIL((int)((ci32 >> 20) & 0x00000fff), ink);
|
|
Shinya Kitaoka |
120a6e |
if (p >= 0) {
|
|
Shinya Kitaoka |
120a6e |
//*pSel=paint.nb
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255 - p;
|
|
Shinya Kitaoka |
120a6e |
nbSel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Tone color
|
|
Shinya Kitaoka |
120a6e |
int p = isInCIL((int)((ci32 >> 8) & 0x00000fff), paint);
|
|
Shinya Kitaoka |
120a6e |
if (p >= 0)
|
|
Shinya Kitaoka |
120a6e |
if (isInCIL((int)((ci32 >> 20) & 0x00000fff), ink) >= 0) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255 - p;
|
|
Shinya Kitaoka |
120a6e |
nbSel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbSel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionCMAP(const COLOR_INDEX_LIST &ink,
|
|
Shinya Kitaoka |
120a6e |
const COLOR_INDEX_LIST &paint) {
|
|
Shinya Kitaoka |
120a6e |
copySel((UCHAR)0);
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_lX > 0 && CSTPic ::m_lY > 0 && m_sel &&
|
|
Shinya Kitaoka |
120a6e |
CSTPic::m_pic && CSTPic ::m_ras) {
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_ras->type == RAS_CM32)
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionCMAP32(ink, paint);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionCMAP(const CCIL &ink, const CCIL &paint) {
|
|
Shinya Kitaoka |
120a6e |
copySel((UCHAR)0);
|
|
Shinya Kitaoka |
120a6e |
COLOR_INDEX_LIST hink, hpaint;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
hink.nb = ink.m_nb;
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < ink.m_nb; i++) hink.ci[i] = (USHORT)ink.m_ci[i];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
hpaint.nb = paint.m_nb;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < paint.m_nb; i++) hpaint.ci[i] = (USHORT)paint.m_ci[i];
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_lX > 0 && CSTPic ::m_lY > 0 && m_sel &&
|
|
Shinya Kitaoka |
120a6e |
CSTPic::m_pic && CSTPic ::m_ras) {
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_ras->type == RAS_CM32)
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionCMAP32(hink, hpaint);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGB(const std::vector<i_pixel> &col, const double dA,</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
const double dAB) {
|
|
Shinya Kitaoka |
120a6e |
int nbCol;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
copySel((UCHAR)0);
|
|
Shinya Kitaoka |
120a6e |
nbCol = col.size();
|
|
Shinya Kitaoka |
120a6e |
if (CSTPic::m_lX > 0 && CSTPic ::m_lY > 0 && m_sel &&
|
|
Shinya Kitaoka |
120a6e |
CSTPic::m_pic) {
|
|
Shinya Kitaoka |
120a6e |
switch (nbCol) {
|
|
Shinya Kitaoka |
120a6e |
case 1:
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionRGB1(col, dA);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 2:
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionRGB2(col, dA, dAB);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case 3:
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionRGB3(col, dA, dAB);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
return makeSelectionRGBMore(col, dA, dAB);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double distRGB2(const I_PIXEL &c1, const I_PIXEL &c2) const {
|
|
Shinya Kitaoka |
120a6e |
double q = (double)(c1.r - c2.r) * (double)(c1.r - c2.r);
|
|
Shinya Kitaoka |
120a6e |
q += (double)(c1.g - c2.g) * (double)(c1.g - c2.g);
|
|
Shinya Kitaoka |
120a6e |
q += (double)(c1.b - c2.b) * (double)(c1.b - c2.b);
|
|
Shinya Kitaoka |
120a6e |
return q;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double distRGBM2(const I_PIXEL &c1, const I_PIXEL &c2) const {
|
|
Shinya Kitaoka |
120a6e |
double q = (double)(c1.r - c2.r) * (double)(c1.r - c2.r);
|
|
Shinya Kitaoka |
120a6e |
q += (double)(c1.g - c2.g) * (double)(c1.g - c2.g);
|
|
Shinya Kitaoka |
120a6e |
q += (double)(c1.b - c2.b) * (double)(c1.b - c2.b);
|
|
Shinya Kitaoka |
120a6e |
q += (double)(c1.m - c2.m) * (double)(c1.m - c2.m);
|
|
Shinya Kitaoka |
120a6e |
return q;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double distRGB(const I_PIXEL &c1, const I_PIXEL &c2) const {
|
|
Shinya Kitaoka |
120a6e |
int qd = (c1.r - c2.r) * (c1.r - c2.r) + (c1.g - c2.g) * (c1.g - c2.g) +
|
|
Shinya Kitaoka |
120a6e |
(c1.b - c2.b) * (c1.b - c2.b);
|
|
Shinya Kitaoka |
120a6e |
return sqrt((double)qd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double distRGBM(const I_PIXEL &c1, const I_PIXEL &c2) const {
|
|
Shinya Kitaoka |
120a6e |
int qd = (c1.r - c2.r) * (c1.r - c2.r) + (c1.g - c2.g) * (c1.g - c2.g) +
|
|
Shinya Kitaoka |
120a6e |
(c1.b - c2.b) * (c1.b - c2.b) * (c1.m - c2.m) * (c1.m - c2.m);
|
|
Shinya Kitaoka |
120a6e |
return sqrt((double)qd);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool isSameColor(const I_PIXEL &c1, const I_PIXEL &c2) const {
|
|
Shinya Kitaoka |
120a6e |
return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setIntPixel(I_PIXEL &dp, const P &sp) const {
|
|
Shinya Kitaoka |
120a6e |
dp.r = (int)sp.r;
|
|
Shinya Kitaoka |
120a6e |
dp.g = (int)sp.g;
|
|
Shinya Kitaoka |
120a6e |
dp.b = (int)sp.b;
|
|
Shinya Kitaoka |
120a6e |
dp.m = (int)sp.m;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline void setIntPixel(I_PIXEL &dp, const P *sp) const {
|
|
Shinya Kitaoka |
120a6e |
dp.r = (int)sp->r;
|
|
Shinya Kitaoka |
120a6e |
dp.g = (int)sp->g;
|
|
Shinya Kitaoka |
120a6e |
dp.b = (int)sp->b;
|
|
Shinya Kitaoka |
120a6e |
dp.m = (int)sp->m;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGB1(const std::vector<i_pixel> &col, const double dA) {</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
P *pPic = CSTPic::m_pic;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
I_PIXEL ip;
|
|
Shinya Kitaoka |
120a6e |
int xy, lxy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Shinya Kitaoka |
120a6e |
int nbPixel = 0;
|
|
Shinya Kitaoka |
120a6e |
double dA2 = dA * dA;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (xy = 0; xy < lxy; xy++, pPic++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
// if ( pPic->m>0 ) {
|
|
Shinya Kitaoka |
120a6e |
setIntPixel(ip, pPic);
|
|
Shinya Kitaoka |
120a6e |
if (ip.m == col[0].m && distRGB2(ip, col[0]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// }
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbPixel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isBetween(const I_PIXEL &a, const I_PIXEL &b, const I_PIXEL &c) const {
|
|
Shinya Kitaoka |
120a6e |
if (c.r < std::min(a.r, b.r)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.r > std::max(a.r, b.r)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.g < std::min(a.g, b.g)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.g > std::max(a.g, b.g)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.b < std::min(a.b, b.b)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.b > std::max(a.b, b.b)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.m < std::min(a.m, b.m)) return false;
|
|
Shinya Kitaoka |
120a6e |
if (c.m > std::max(a.m, b.m)) return false;
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Toshihiro Shimizu |
890ddd |
//if ( c.m!=0 )
|
|
Shinya Kitaoka |
120a6e |
// tmsg_info("A=(%d,%d,%d,%d) B=(%d,%d,%d,%d)
|
|
Shinya Kitaoka |
120a6e |
C=(%d,%d,%d,%d)\n",a.r,a.g,a.b,a.m,b.r,b.g,b.b,b.m,c.r,c.g,c.b,c.m);
|
|
Shinya Kitaoka |
120a6e |
if ( c.r
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.r>a.r && c.r>b.r )
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.g
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.g>a.g && c.g>b.g )
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.b
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.b>a.b && c.b>b.b )
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.m
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if ( c.m>a.m && c.m>b.m )
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
//if ( c.m!=0 )
|
|
Toshihiro Shimizu |
890ddd |
//tmsg_info("IS_BETWEEN");
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isLinComb(const I_PIXEL &a, const I_PIXEL &b, const I_PIXEL &c,
|
|
Shinya Kitaoka |
120a6e |
const double dAB) {
|
|
Shinya Kitaoka |
120a6e |
// if ( isSameColor(a,b) && isSameColor(a,c) )
|
|
Shinya Kitaoka |
120a6e |
// return true;
|
|
Shinya Kitaoka |
120a6e |
if (!isBetween(a, b, c)) return false;
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
/* double dab=distRGBM(a,b);
|
|
Shinya Kitaoka |
120a6e |
double dac=distRGBM(a,c);
|
|
Shinya Kitaoka |
120a6e |
double dbc=distRGBM(b,c);
|
|
Shinya Kitaoka |
120a6e |
double d= dab-(dac+dbc);
|
|
Shinya Kitaoka |
120a6e |
d= d<0.0 ? -d : d;
|
|
Shinya Kitaoka |
120a6e |
if ( d<=dAB )
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGB2(const std::vector<i_pixel> &col, const double dA,</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
const double dAB) {
|
|
Shinya Kitaoka |
120a6e |
P *pPic;
|
|
Shinya Kitaoka |
120a6e |
UCHAR *pSel;
|
|
Shinya Kitaoka |
120a6e |
I_PIXEL ip;
|
|
Shinya Kitaoka |
120a6e |
int xy, lxy, nbPixel;
|
|
Shinya Kitaoka |
120a6e |
double dA2 = dA * dA;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
nbPixel = 0;
|
|
Shinya Kitaoka |
120a6e |
pPic = CSTPic::m_pic;
|
|
Rozhuk Ivan |
697eaf |
pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
lxy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Shinya Kitaoka |
120a6e |
for (xy = 0; xy < lxy; xy++, pPic++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
// if ( pPic->m>0 ) {
|
|
Shinya Kitaoka |
120a6e |
setIntPixel(ip, pPic);
|
|
Shinya Kitaoka |
120a6e |
if (ip.m == col[0].m && distRGB2(ip, col[0]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (ip.m == col[1].m && distRGB2(ip, col[1]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = (UCHAR)(255 - 1);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (isLinComb(col[0], col[1], ip, dAB)) {
|
|
Shinya Kitaoka |
120a6e |
// *pSel=(UCHAR)253;
|
|
Shinya Kitaoka |
120a6e |
*pSel = distRGBM2(col[0], ip) < distRGBM2(col[1], ip)
|
|
Shinya Kitaoka |
120a6e |
? 255
|
|
Shinya Kitaoka |
120a6e |
: (UCHAR)(255 - 1);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// }
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbPixel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGB3(const std::vector<i_pixel> &col, const double dA,</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
const double dAB) {
|
|
Shinya Kitaoka |
120a6e |
P *pPic = CSTPic::m_pic;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
I_PIXEL ip;
|
|
Shinya Kitaoka |
120a6e |
int xy, nbPixel = 0;
|
|
Shinya Kitaoka |
120a6e |
int lxy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Shinya Kitaoka |
120a6e |
double dA2 = dA * dA;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (xy = 0; xy < lxy; xy++, pPic++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
// if ( pPic->m>0 ) {
|
|
Shinya Kitaoka |
120a6e |
setIntPixel(ip, pPic);
|
|
Shinya Kitaoka |
120a6e |
if (ip.m == col[0].m && distRGB2(ip, col[0]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = 255;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (ip.m == col[1].m && distRGB2(ip, col[1]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = (UCHAR)(255 - 1);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (ip.m == col[2].m && distRGB2(ip, col[2]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = (UCHAR)(255 - 2);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (isLinComb(col[0], col[1], ip, dAB)) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = distRGBM2(col[0], ip) < distRGBM2(col[1], ip) ? 255 : 255 - 1;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (isLinComb(col[0], col[2], ip, dAB)) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = distRGBM2(col[0], ip) < distRGBM2(col[2], ip) ? 255 : 255 - 2;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (isLinComb(col[1], col[2], ip, dAB)) {
|
|
Shinya Kitaoka |
120a6e |
*pSel =
|
|
Shinya Kitaoka |
120a6e |
distRGBM2(col[1], ip) < distRGBM2(col[2], ip) ? 255 - 1 : 255 - 2;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// }
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbPixel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGBMore(const std::vector<i_pixel> &col, const double dA,</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
const double dAB) {
|
|
Shinya Kitaoka |
120a6e |
int nbPixel = 0, i, j, k;
|
|
Shinya Kitaoka |
120a6e |
int nbCol = col.size();
|
|
Shinya Kitaoka |
120a6e |
for (i = 1, k = 0; i < nbCol; i++)
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < i; j++) {
|
|
Shinya Kitaoka |
120a6e |
nbPixel += makeSelectionRGBMore(col, dA, dAB, i, j, k);
|
|
Shinya Kitaoka |
120a6e |
k++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbPixel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int makeSelectionRGBMore(const std::vector<i_pixel> &col, const double dA,</i_pixel>
|
|
Shinya Kitaoka |
120a6e |
const double dAB, const int i, const int j,
|
|
Shinya Kitaoka |
120a6e |
const int k) {
|
|
Shinya Kitaoka |
120a6e |
P *pPic = CSTPic::m_pic;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
I_PIXEL ip;
|
|
Shinya Kitaoka |
120a6e |
int nbPixel = 0;
|
|
Shinya Kitaoka |
120a6e |
double dA2 = dA * dA;
|
|
Shinya Kitaoka |
120a6e |
int nbCol = col.size();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < CSTPic::m_lY; y++)
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < CSTPic::m_lX; x++, pPic++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
// if ( pPic->m>0 ) {
|
|
Shinya Kitaoka |
120a6e |
setIntPixel(ip, pPic);
|
|
Shinya Kitaoka |
120a6e |
if (ip.m == col[i].m && distRGB2(ip, col[i]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = (UCHAR)(255 - i);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (ip.m == col[j].m && distRGB2(ip, col[j]) <= dA2) {
|
|
Shinya Kitaoka |
120a6e |
*pSel = (UCHAR)(255 - j);
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
} else if (isLinComb(col[i], col[j], ip, dAB)) {
|
|
Shinya Kitaoka |
120a6e |
*pSel =
|
|
Shinya Kitaoka |
120a6e |
distRGBM2(col[i], ip) < distRGBM2(col[j], ip) ? 255 - i : 255 - j;
|
|
Shinya Kitaoka |
120a6e |
nbPixel++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// }
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return nbPixel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setSel01() {
|
|
Shinya Kitaoka |
120a6e |
int xy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *p = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < xy; i++, p++) *p = *p > (UCHAR)0 ? (UCHAR)1 : (UCHAR)0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void showSelection() {
|
|
Shinya Kitaoka |
120a6e |
P *pPic;
|
|
Shinya Kitaoka |
120a6e |
UCHAR *pSel;
|
|
Shinya Kitaoka |
120a6e |
int lxy, xy;
|
|
Shinya Kitaoka |
120a6e |
int fcolor;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
lxy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Rozhuk Ivan |
697eaf |
pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
pPic = CSTPic::m_pic;
|
|
Shinya Kitaoka |
120a6e |
bool isRGBMType = CSTPic::getType() == ST_RGBM;
|
|
Shinya Kitaoka |
120a6e |
fcolor = isRGBMType ? 255 : 65535;
|
|
Shinya Kitaoka |
120a6e |
for (xy = 0; xy < lxy; xy++, pPic++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
/* if (*pSel==(UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=fcolor/2;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
if (*pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r = 255;
|
|
Shinya Kitaoka |
120a6e |
pPic->g = 0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b = 0;
|
|
Shinya Kitaoka |
120a6e |
pPic->m = fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/* if (*pSel==(UCHAR)2) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (*pSel==(UCHAR)3) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
/* if (*pSel==(UCHAR)255) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (*pSel==(UCHAR)254) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (*pSel==(UCHAR)253) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (*pSel==(UCHAR)251) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (*pSel==(UCHAR)250) {
|
|
Shinya Kitaoka |
120a6e |
pPic->r=0;
|
|
Shinya Kitaoka |
120a6e |
pPic->g=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->b=fcolor;
|
|
Shinya Kitaoka |
120a6e |
pPic->m=fcolor;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void selBox(SRECT &box) {
|
|
Shinya Kitaoka |
120a6e |
box.x0 = CSTPic::m_lX;
|
|
Shinya Kitaoka |
120a6e |
box.x1 = -1;
|
|
Shinya Kitaoka |
120a6e |
box.y0 = CSTPic::m_lY;
|
|
Shinya Kitaoka |
120a6e |
box.y1 = -1;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
for (int y = 0; y < CSTPic::m_lY; y++)
|
|
Shinya Kitaoka |
120a6e |
for (int x = 0; x < CSTPic::m_lX; x++, pSel++)
|
|
Shinya Kitaoka |
120a6e |
if (*pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
box.x0 = std::min(box.x0, x);
|
|
Shinya Kitaoka |
120a6e |
box.x1 = std::max(box.x1, x);
|
|
Shinya Kitaoka |
120a6e |
box.y0 = std::min(box.y0, y);
|
|
Shinya Kitaoka |
120a6e |
box.y1 = std::max(box.y1, y);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void selRunLengthH(const SRECT &box, const int step, int &rl, int &nbRl) {
|
|
Shinya Kitaoka |
120a6e |
for (int y = box.y0; y <= (box.y1); y += step) {
|
|
Shinya Kitaoka |
120a6e |
int l = 0;
|
|
Shinya Kitaoka |
120a6e |
bool isIn = false;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get() + y * CSTPic::m_lX + box.x0;
|
|
Shinya Kitaoka |
120a6e |
for (int x = box.x0; x <= box.x1; x++, pSel++) {
|
|
Shinya Kitaoka |
120a6e |
if (isIn && *pSel == (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
rl += l;
|
|
Shinya Kitaoka |
120a6e |
nbRl++;
|
|
Shinya Kitaoka |
120a6e |
l = 0;
|
|
Shinya Kitaoka |
120a6e |
isIn = false;
|
|
Shinya Kitaoka |
120a6e |
} else if (isIn && *pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
l++;
|
|
Shinya Kitaoka |
120a6e |
} else if (!isIn && *pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
l = 1;
|
|
Shinya Kitaoka |
120a6e |
isIn = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (isIn) {
|
|
Shinya Kitaoka |
120a6e |
rl += l;
|
|
Shinya Kitaoka |
120a6e |
nbRl++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void selRunLengthV(const SRECT &box, const int step, int &rl, int &nbRl) {
|
|
Shinya Kitaoka |
120a6e |
for (int x = box.x0; x <= (box.x1); x += step) {
|
|
Shinya Kitaoka |
120a6e |
int l = 0;
|
|
Shinya Kitaoka |
120a6e |
bool isIn = false;
|
|
Shinya Kitaoka |
120a6e |
for (int y = box.y0; y <= box.y1; y++) {
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get() + y * CSTPic::m_lX + x;
|
|
Shinya Kitaoka |
120a6e |
if (isIn && *pSel == (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
rl += l;
|
|
Shinya Kitaoka |
120a6e |
nbRl++;
|
|
Shinya Kitaoka |
120a6e |
l = 0;
|
|
Shinya Kitaoka |
120a6e |
isIn = false;
|
|
Shinya Kitaoka |
120a6e |
} else if (isIn && *pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
l++;
|
|
Shinya Kitaoka |
120a6e |
} else if (!isIn && *pSel > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
l = 1;
|
|
Shinya Kitaoka |
120a6e |
isIn = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (isIn) {
|
|
Shinya Kitaoka |
120a6e |
rl += l;
|
|
Shinya Kitaoka |
120a6e |
nbRl++;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int selRunLength(const int step) {
|
|
Shinya Kitaoka |
120a6e |
int s = step < 1 ? 1 : step;
|
|
Shinya Kitaoka |
120a6e |
SRECT box;
|
|
Shinya Kitaoka |
120a6e |
selBox(box);
|
|
Shinya Kitaoka |
120a6e |
int rl = 0;
|
|
Shinya Kitaoka |
120a6e |
int nbRl = 0;
|
|
Shinya Kitaoka |
120a6e |
selRunLengthH(box, s, rl, nbRl);
|
|
Shinya Kitaoka |
120a6e |
selRunLengthV(box, s, rl, nbRl);
|
|
Shinya Kitaoka |
120a6e |
if (nbRl > 0) {
|
|
Shinya Kitaoka |
120a6e |
double d = (double)rl / (double)nbRl;
|
|
Shinya Kitaoka |
120a6e |
return I_ROUNDP(d);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void hlsNoise(const double d) {
|
|
Shinya Kitaoka |
120a6e |
int xy = CSTPic::m_lX * CSTPic ::m_lY;
|
|
Shinya Kitaoka |
120a6e |
P *p = CSTPic::m_pic;
|
|
Rozhuk Ivan |
697eaf |
UCHAR *pSel = m_sel.get();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < xy; i++, p++, pSel++)
|
|
Shinya Kitaoka |
120a6e |
if (p->m > 0 && (*pSel) > (UCHAR)0) {
|
|
Shinya Kitaoka |
120a6e |
double h, l, s, q;
|
|
Shinya Kitaoka |
120a6e |
rgb2hls(p->r, p->g, p->b, &h, &l, &s);
|
|
Shinya Kitaoka |
120a6e |
q = 1.0 - d * (double)((rand() % 201) - 100) / 100.0;
|
|
Shinya Kitaoka |
120a6e |
l *= q;
|
|
Shinya Kitaoka |
120a6e |
hls2rgb(h, l, s, &(p->r), &(p->g), &(p->b));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Toshihiro Shimizu |
890ddd |
void expand(const int border) throw(SMemAllocError)
|
|
Toshihiro Shimizu |
890ddd |
{ try {
|
|
Shinya Kitaoka |
120a6e |
int olX=m_lX;
|
|
Shinya Kitaoka |
120a6e |
int olY=m_lY;
|
|
Shinya Kitaoka |
120a6e |
CSTPic::expand(border);
|
|
Shinya Kitaoka |
120a6e |
UCHAR* nSel=new UCHAR[m_lX*m_lY];
|
|
Shinya Kitaoka |
120a6e |
if ( !nSel )
|
|
Shinya Kitaoka |
120a6e |
throw SMemAllocError("in expand");
|
|
Shinya Kitaoka |
120a6e |
UCHAR* pNSel=nSel;
|
|
Shinya Kitaoka |
120a6e |
for( int y=0; y
|
|
Shinya Kitaoka |
120a6e |
for( int x=0; x
|
|
Shinya Kitaoka |
120a6e |
int ox=x-border;
|
|
Shinya Kitaoka |
120a6e |
int oy=y-border;
|
|
Shinya Kitaoka |
120a6e |
if ( ox>=0 && ox<olx &&="" oy="">=0 && oy</olx>
|
|
Shinya Kitaoka |
120a6e |
*pNSel=*(m_sel+oy*olX+ox);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
*pNSel=(UCHAR)0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
delete [] m_sel;
|
|
Shinya Kitaoka |
120a6e |
m_sel=nSel;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
catch (SMemAllocError) {
|
|
Shinya Kitaoka |
120a6e |
throw;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // !defined(AFX_STCOLSELPIC_H__80D708B0_FCA2_11D5_B949_0040F674BE6A__INCLUDED_)
|