void TextFormatter::Highlight() { if (!m_hllen || m_hlstart.docid != DocId()) return; FilePos hls(m_hlstart); int hll = m_hllen; for (int i = 0; i < m_lines.GetSize(); ++i) if (hls.para == m_lines[i].pos.para) { int beg, len; if (hls.off - m_lines[i].pos.off < m_lines[i].real_len && intersect(hls.off, hll, m_lines[i].pos.off, m_lines[i].str.size(), beg, len)) { int top = beg + len; while (beg < top) m_lines[i].attr[beg++].hibg = true; m_lines[i].flags &= ~Line::defstyle; } else m_lines[i].CheckStyle(); // advance our pointer if (i<m_lines.GetSize() - 1 && m_lines[i + 1].pos.para>hls.para && hls.off + hll > m_tf->GetPLength(hls.docid, hls.para)) { hll -= m_tf->GetPLength(hls.docid, hls.para) - hls.off; ++hls.para; hls.off = 0; } } else m_lines[i].CheckStyle(); }
cv::Mat fourier::bgr(const cv::Mat &fourier) { const cv::Size &size = fourier.size(); cv::Mat hls(size, CV_8UC3); std::vector<cv::Mat> plane; cv::split(fourier, plane); cv::Mat mag; cv::magnitude(plane[0], plane[1], mag); mag += cv::Scalar::all(1); cv::log(mag, mag); cv::normalize(mag, mag, 127, 255, CV_MINMAX); cv::Mat pha; cv::phase(plane[1], plane[0], pha); cv::normalize(pha, pha, 0, 127, CV_MINMAX); for (int i = 0, m = size.height; i < m; i++) { for (int j = 0, n = size.width; j < n; j++) { cv::Vec3b &pixel = hls.at<cv::Vec3b>(i, j); pixel[0] = (uchar) pha.at<float>(i, j); pixel[1] = (uchar) mag.at<float>(i, j); pixel[2] = 255; } } cv::Mat rgb; cv::cvtColor(hls, rgb, CV_HLS2BGR); return rgb; }
void CGradientPt::RotateHue(bool HLSMode, double Rotation) { if (HLSMode) { DHLS hls(m_Color.hls); hls.RotateHue(Rotation); m_Color.hls = hls; } else { DRGB rgb(m_Color.rgb); rgb.RotateHue(Rotation); m_Color.rgb = rgb; } }
void CGradientPt::Invert(bool HLSMode) { if (HLSMode) { DHLS hls(m_Color.hls); hls.Invert(); m_Color.hls = hls; } else { DRGB rgb(m_Color.rgb); rgb.Invert(); m_Color.rgb = rgb; } }
nux::color::RedGreenBlue ProduceColorShade(nux::color::RedGreenBlue const& rgb, float shade) { if (shade == 1.0f) return rgb; nux::color::HueLightnessSaturation hls(rgb); hls.lightness *= shade; if (hls.lightness > 1.0f) hls.lightness = 1.0f; else if (hls.lightness < 0.0f) hls.lightness = 0.0f; hls.saturation *= shade; if (hls.saturation > 1.0f) hls.saturation = 1.0f; else if (hls.saturation < 0.0f) hls.saturation = 0.0f; nux::color::RedGreenBlue rgb_shade(hls); return rgb_shade; }
int main(int argc, char *argv[]) { int opt; bool feed_stdout = false; char url[2048] = { 0 }; while ((opt = getopt(argc, argv, "i:o")) != -1) { switch (opt) { case 'i': if (!optarg) { fprintf(stderr, "missing argument\n"); return -1; } strncpy(url, optarg, sizeof(url)); break; case 'o': feed_stdout = true; break; } } hlsinput hls(feed_stdout); hls.get(url); }