예제 #1
0
    inline void
    dag_sp_dispatch1
      (const VertexListGraph& g,
       typename graph_traits<VertexListGraph>::vertex_descriptor s, 
       DistanceMap distance, WeightMap weight, ColorMap color, IndexMap id,
       DijkstraVisitor vis, const Params& params)
    {
      typedef typename property_traits<WeightMap>::value_type T;
      typename std::vector<T>::size_type n;
      n = is_default_param(distance) ? num_vertices(g) : 1;
      std::vector<T> distance_map(n);
      n = is_default_param(color) ? num_vertices(g) : 1;
      std::vector<default_color_type> color_map(n);

      dag_sp_dispatch2
        (g, s, 
         choose_param(distance, 
                      make_iterator_property_map(distance_map.begin(), id,
                                                 distance_map[0])),
         weight, 
         choose_param(color,
                      make_iterator_property_map(color_map.begin(), id, 
                                                 color_map[0])),
         id, vis, params);
    }
예제 #2
0
void TextureObject::update( kvs::ni::UserGenerator& user )
{
    kvs::ColorMap color_map( 5 );
    color_map.create();

    kvs::ValueArray<unsigned int> users = user.users();
    m_data.fill( 0x00 );

    for ( size_t i = 0; i < users.size(); i++ )
    {
        const unsigned short* p_user = user.pointer( users[i] );
        const size_t color_index = users[i] % 5;
        kvs::RGBColor color = color_map[ color_index ];
        const float ratio = ( user.skeleton().isTracking( users[i] ) ) ? 1.0f : 0.5f;
        for ( size_t y = 0; y < m_height; y++ )
        {
            for ( size_t x = 0; x < m_width; x++ )
            {
                const size_t index = x + y * m_width;
                if ( p_user[ index ] == users[i] )
                {
                    m_data[ index * 4     ] = static_cast<unsigned char>( ratio * color.r() );
                    m_data[ index * 4 + 1 ] = static_cast<unsigned char>( ratio * color.g() );
                    m_data[ index * 4 + 2 ] = static_cast<unsigned char>( ratio * color.b() );
                    m_data[ index * 4 + 3 ] = 255;
                }
            }
        }
    }
}
예제 #3
0
void TransferFunctionEditor::setTransferFunction( const kvs::TransferFunction& transfer_function )
{
    const kvs::ColorMap& cmap = transfer_function.colorMap();
    const kvs::OpacityMap& omap = transfer_function.opacityMap();

    // Deep copy for the initial transfer function.
    kvs::ColorMap::Table color_map_table( cmap.table().data(), cmap.table().size() );
    kvs::OpacityMap::Table opacity_map_table( omap.table().data(), omap.table().size() );
//    kvs::ColorMap color_map( color_map_table, cmap.minValue(), cmap.maxValue() );
//    kvs::OpacityMap opacity_map( opacity_map_table, omap.minValue(), omap.maxValue() );
    kvs::ColorMap color_map( color_map_table );
    kvs::OpacityMap opacity_map( opacity_map_table );
    m_initial_transfer_function.setColorMap( color_map );
    m_initial_transfer_function.setOpacityMap( opacity_map );

    if ( transfer_function.hasRange() )
    {
        m_min_value = transfer_function.colorMap().minValue();
        m_max_value = transfer_function.colorMap().maxValue();
        m_initial_transfer_function.setRange( m_min_value, m_max_value );
    }

    m_color_map_palette->setColorMap( color_map );
    m_opacity_map_palette->setOpacityMap( opacity_map );

    m_undo_stack.clear();
    m_undo_stack.push_front( m_initial_transfer_function );
}
예제 #4
0
void WindowSput (PCONINFO con, u_char ch, int fc, int bc, int pos)
{
    char szCharBuff [2];
    HDC hdc;
    int col, row;

    szCharBuff [0] = ch;
    szCharBuff [1] = '\0';
   
    col = pos % con->cols;
    row = pos / con->cols;
   
    hdc = GetPrivateClientDC (con->hWnd);
    SetTextColor (hdc, SysColorIndex [color_map (fc) & 0x0F]);
    SetBkColor (hdc, SysColorIndex [color_map (bc) & 0x0F]);
    TextOut (hdc, col * GetCharWidth (), row * GetCharHeight (), szCharBuff);
}
예제 #5
0
void WindowClearAll (PCONINFO con, int color)
{
    HDC hdc;
    RECT rcClient;
    
    GetClientRect (con->hWnd, &rcClient);

    hdc = GetPrivateClientDC (con->hWnd);
    SetBrushColor (hdc, SysColorIndex [color_map (color)]);
    FillBox (hdc, rcClient.left, rcClient.top,
                  RECTW (rcClient), RECTH (rcClient));
}
예제 #6
0
void WindowStringPut (PCONINFO con, const char* text, 
                            int fc, int bc, int x, int y)
{
    HDC hdc;
    
#if 0
    {
    FILE *fff;

    fff = fopen("/tmp/ccegb-output.log", "a");
    fprintf (fff,"x=%d, y=%d, fc=%d, bc=%d, text=%s\n", 
                x, y, fc, bc, text);
	fclose (fff);
    }
#endif

    x *= GetCharWidth ();
    y *= GetCharHeight ();

    hdc = GetPrivateClientDC (con->hWnd);
    SetTextColor (hdc, SysColorIndex [color_map (fc) & 0x0F]);
    SetBkColor (hdc, SysColorIndex [color_map (bc) & 0x0000000F]);
    TextOut (hdc, x, y, text);
}
예제 #7
0
void *color_processing(void *pointer) {
	Mat *imgPtr = (Mat *) pointer;
	vector <gpu::GpuMat > color_map(12);
	gpu::GpuMat inputGPU(*imgPtr);

        color_map = Normalize_color_GPU(inputGPU);
	vector <gpu::GpuMat> RGBYMap(6);

	for (int i = 0; i < 6; i++)
		gpu::addWeighted(color_map[i], 0.5, color_map[i + 6], 0.5, 0, RGBYMap[i],
				-1);

	 gpu::GpuMat AggColGPU = aggregateMaps_GPU(RGBYMap);
	 gpu::normalize(AggColGPU, AggColGPU, 0, 255, NORM_MINMAX, -1);
         AggColGPU.download(AggColor);

	pthread_exit (NULL);
}
예제 #8
0
// Capture Example demonstrates how to
// capture depth and color video streams and render them to the screen
int main(int argc, char * argv[]) try
{
    // Create a simple OpenGL window for rendering:
    window app(1280, 720, "RealSense Capture Example");
    // Declare two textures on the GPU, one for color and one for depth
    texture depth_image, color_image;

    // Declare depth colorizer for pretty visualization of depth data
    rs2::colorizer color_map;

    // Declare RealSense pipeline, encapsulating the actual device and sensors
    rs2::pipeline pipe;
    // Start streaming with default recommended configuration
    pipe.start();

    while(app) // Application still alive?
    {
        rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera

        rs2::frame depth = color_map(data.get_depth_frame()); // Find and colorize the depth data
        rs2::frame color = data.get_color_frame();            // Find the color data

        // Render depth on to the first half of the screen and color on to the second
        depth_image.render(depth, { 0,               0, app.width() / 2, app.height() });
        color_image.render(color, { app.width() / 2, 0, app.width() / 2, app.height() });
    }

    return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
    std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n    " << e.what() << std::endl;
    return EXIT_FAILURE;
}
catch (const std::exception& e)
{
    std::cerr << e.what() << std::endl;
    return EXIT_FAILURE;
}
예제 #9
0
  Image* OpenTGA(File* file) {
    COR_GUARD("OpenTGA");

    // read header
    byte header[18];
    if (file->read(header, 18) != 18) {
      return 0;
    }

    // decode header
    int id_length        = header[0];
    int cm_type          = header[1];
    int image_type       = header[2];
    //int cm_first         = read16_le(header + 3);
    int cm_length        = read16_le(header + 5);
    int cm_entry_size    = header[7];  // in bits
    //int x_origin         = read16_le(header + 8);
    //int y_origin         = read16_le(header + 10);
    int width            = read16_le(header + 12);
    int height           = read16_le(header + 14);
    int pixel_depth      = header[16];
    int image_descriptor = header[17];
    
    bool mirrored = (image_descriptor & (1 << 4)) != 0;  // left-to-right?
    bool flipped  = (image_descriptor & (1 << 5)) == 0;  // bottom-to-top?

    /*
     * image types
     * 0  = no image data
     * 1  = uncompressed, color-mapped
     * 2  = uncompressed, true-color
     * 3  = uncompressed, black and white
     * 9  = RLE, color-mapped
     * 10 = RLE, true-color
     * 11 = RLE, black and white
     */

    // make sure we support the image
    if (image_type != 2 || (pixel_depth != 24 && pixel_depth != 32)) {
      return 0;
    }

    // skip image id
    byte unused[255];
    if (file->read(unused, id_length) != id_length) {
      return 0;
    }

    // skip color map
    if (cm_type != 0) {
      // allocate color map
      int cm_entry_bytes = (cm_entry_size + 7) / 8;
      int cm_size = cm_entry_bytes * cm_length;
      auto_array<byte> color_map(new byte[cm_size]);
      if (file->read(color_map, cm_size) != cm_size) {
        return 0;
      }
    }

    // read image data
    PixelFormat format;
    auto_array<byte> pixels;
    if (pixel_depth == 24) {

      COR_LOG("24-bit image");

      format = PF_B8G8R8;
      int image_size = width * height * 3;
      pixels = new byte[image_size];
      if (file->read(pixels, image_size) != image_size) {
        return 0;
      }

    } else if (pixel_depth == 32) {

      COR_LOG("32-bit image");

      format = PF_B8G8R8A8;
      int image_size = width * height * 4;
      pixels = new byte[image_size];
      if (file->read(pixels, image_size) != image_size) {
        return 0;
      }

    } else {
      return 0;
    }

    // reverse each row
    if (mirrored) {
      COR_LOG("Image is mirrored");

      const int bpp = pixel_depth / 8;  // bytes per pixel
      for (int y = 0; y < height; ++y) {

	// points to the first pixel of the row
	byte* start = pixels.get() + y * width * bpp;
	// points to the last pixel of the row
	byte* end   = start + (width - 1) * bpp;

	while (start < end) {
	  for (int b = 0; b < bpp; ++b) {
	    std::swap(start[b], end[b]);
	  }
	  start += bpp;
	  end   -= bpp;
	}
      }
    }

    // reverse rows as a whole
    if (flipped) {
      COR_LOG("Image is flipped");

      const int bpp = pixel_depth / 8;  // bytes per pixel
      const int row_size = width * bpp;
      auto_array<byte> temp(new byte[row_size]);  // for the swap

      // points to the beginning of the first row
      byte* start = pixels.get();

      // points to the beginning of the last row
      byte* end   = start + (height - 1) * width * bpp;

      while (start < end) {
	memcpy(temp.get(), start,      row_size);
	memcpy(start,      end,        row_size);
	memcpy(end,        temp.get(), row_size);

	start += row_size;
	end   -= row_size;
      }
    }

    return new SimpleImage(width, height, format, pixels.release());
  }
예제 #10
0
vector<gpu::GpuMat> Normalize_color_GPU(gpu::GpuMat inputImage)
{

//generate the channel y
vector<gpu::GpuMat> rgby(4);
vector<gpu::GpuMat> temp;
gpu::split(inputImage, temp);

gpu::GpuMat interm4;
gpu::addWeighted(temp[1], 0.5, temp[2], 0.5, 0, interm4, -1);
gpu::subtract(temp[0],interm4,rgby[0]);

gpu::GpuMat interm5;
gpu::addWeighted(temp[0], 0.5, temp[2], 0.5, 0, interm5, -1);
gpu::subtract(temp[1],interm5,rgby[1]);

gpu::GpuMat interm6;
gpu::addWeighted(temp[1], 0.5, temp[0], 0.5, 0, interm6, -1);
gpu::subtract(temp[2],interm6,rgby[2]);

gpu::GpuMat interm7;
gpu::addWeighted(temp[2], 0.5, temp[1], 0.5, 0, interm7, -1);
gpu::GpuMat interm; 
gpu::absdiff(temp[2],temp[1], interm); 
gpu::divide(0.5,interm,interm);
gpu::GpuMat interm8;
gpu::subtract(interm7,interm,interm8);

gpu::subtract(interm8,temp[0],rgby[3]);

gpu::threshold(rgby[3], rgby[3], 0, 255, THRESH_TOZERO);

vector<gpu::GpuMat> red_pyr(9);
vector<gpu::GpuMat> green_pyr(9);
vector<gpu::GpuMat> blue_pyr(9);
vector<gpu::GpuMat> yellow_pyr(9);

red_pyr = Get_GaussianPyramid_GPU(rgby[2]);
green_pyr = Get_GaussianPyramid_GPU(rgby[1]);
blue_pyr = Get_GaussianPyramid_GPU(rgby[0]);
yellow_pyr = Get_GaussianPyramid_GPU(rgby[3]);

gpu::GpuMat r_g, b_y, output_rg, output_by;
vector<gpu::GpuMat> color_map(12);

for(int c = 2; c<=4; c++)
{
	for(int delta = 3; delta<=4; delta++)
	{
               gpu::subtract(green_pyr[c+delta],red_pyr[c+delta],r_g);
                gpu::subtract(yellow_pyr[c+delta],blue_pyr[c+delta],b_y);

		for(int bCtr =1; bCtr<=delta; bCtr++)
		{
			gpu::pyrUp(r_g, output_rg);
			//r_g = output_rg;
			gpu::pyrUp(b_y, output_by);
			//b_y = output_by;
		}
		if(red_pyr[c].size() != output_rg.size())
		{
                       gpu::GpuMat interm2;
                        gpu::resize(output_rg, output_rg,red_pyr[c].size(),1.0,1.0);  
                        gpu::subtract(red_pyr[c],green_pyr[c],interm2);
                        gpu::absdiff(interm2, output_rg, color_map[2*c+delta-7]);

                        gpu::GpuMat interm3;
                        gpu::resize(output_by, output_by,red_pyr[c].size(),1.0,1.0);  
                        gpu::subtract(blue_pyr[c],yellow_pyr[c],interm3);
                        gpu::absdiff(interm3, output_by, color_map[2*c+delta-1]);
		}
		else
		{
                        gpu::GpuMat interm2;
                        gpu::subtract(red_pyr[c],green_pyr[c],interm2);
                        gpu::GpuMat interm3;
                        gpu::subtract(blue_pyr[c],yellow_pyr[c],interm3);
                                            
                        gpu::absdiff(interm2, output_rg, color_map[2*c+delta-7]);
                        gpu::absdiff(interm3, output_by, color_map[2*c+delta-1]);
		}
	}
}

return color_map;
}
예제 #11
0
vector<Mat> Normalize_color(Mat inputImage, Mat IntensityImg)
{

	double maxInt;

	minMaxLoc(IntensityImg, NULL, &maxInt, NULL, NULL);

//Normalize all color channels
int i = 0, j = 0;
Vec3b intensity = inputImage.at<Vec3b>(i,j);

	for(i=0; i<inputImage.rows; i++)//row
	{
		for(j=0; j<inputImage.cols; j++)//
		{
			if(inputImage.at<uchar>(i, j) >= 0.1 * maxInt)
			{
				intensity.val[0] = (intensity.val[0] * 255)/maxInt;//b
				intensity.val[1] = (intensity.val[1] * 255)/maxInt;//g
				intensity.val[2] = (intensity.val[2] * 255)/maxInt;//r	
				
			}
		}
	}

//generate the channel y
vector<Mat> rgby(4);
vector<Mat> temp;
split(inputImage, temp);

rgby[0] = temp[0] - (temp[1] + temp[2])/2;
rgby[1] = temp[1] - (temp[0] + temp[2])/2;
rgby[2] = temp[2] - (temp[1] + temp[0])/2;
rgby[3] = (temp[2] + temp[1])/2 - abs((temp[2] - temp[1])/2) - temp[0];

threshold(rgby[3], rgby[3], 0, 255, THRESH_TOZERO);
vector<Mat> red_pyr(9);
vector<Mat> green_pyr(9);
vector<Mat> blue_pyr(9);
vector<Mat> yellow_pyr(9);

red_pyr = Get_GaussianPyramid(rgby[2]);
green_pyr = Get_GaussianPyramid(rgby[1]);
blue_pyr = Get_GaussianPyramid(rgby[0]);
yellow_pyr = Get_GaussianPyramid(rgby[3]);

Mat r_g, b_y, output_rg, output_by;
vector<Mat> color_map(12);

for(int c = 2; c<=4; c++)
{
	for(int delta = 3; delta<=4; delta++)
	{
		r_g = green_pyr[c+delta] - red_pyr[c+delta];
		b_y = yellow_pyr[c+delta] - blue_pyr[c+delta];
		for(int bCtr =1; bCtr<=delta; bCtr++)
		{
			pyrUp(r_g, output_rg, Size(r_g.cols*2, r_g.rows*2));
			r_g = output_rg;
			pyrUp(b_y, output_by, Size(b_y.cols*2, b_y.rows*2));
			b_y = output_by;
		}
		if(red_pyr[c].size() != output_rg.size())
		{
			color_map[2*c+delta-7] = abs((red_pyr[c] - green_pyr[c]) - output_rg(Range(0, red_pyr[c].rows), Range(0, red_pyr[c].cols)));
color_map[2*c+delta-1] = abs((blue_pyr[c] - yellow_pyr[c]) - output_by(Range(0, red_pyr[c].rows), Range(0, red_pyr[c].cols)));
		}
		else
		{
			color_map[2*c+delta-7] = abs((red_pyr[c] - green_pyr[c]) - output_rg);
			color_map[2*c+delta-1] = abs((blue_pyr[c] - yellow_pyr[c]) - output_by);
		}
	}
}

return color_map;
}
예제 #12
0
      bool test_isomorphism()
      {
        {
          std::vector<invar1_value> invar1_array;
          BGL_FORALL_VERTICES_T(v, G1, Graph1)
            invar1_array.push_back(invariant1(v));
          sort(invar1_array);
        
          std::vector<invar2_value> invar2_array;
          BGL_FORALL_VERTICES_T(v, G2, Graph2)
            invar2_array.push_back(invariant2(v));
          sort(invar2_array);
          if (! equal(invar1_array, invar2_array))
            return false;
        }
        
        std::vector<vertex1_t> V_mult;
        BGL_FORALL_VERTICES_T(v, G1, Graph1)
          V_mult.push_back(v);
        {
          std::vector<size_type> multiplicity(max_invariant, 0);
          BGL_FORALL_VERTICES_T(v, G1, Graph1)
            ++multiplicity[invariant1(v)];
          sort(V_mult, compare_multiplicity(invariant1, &multiplicity[0]));
        }
        
        std::vector<default_color_type> color_vec(num_vertices(G1));
        safe_iterator_property_map<std::vector<default_color_type>::iterator,
                                   IndexMap1
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
                                   , default_color_type, default_color_type&
#endif /* BOOST_NO_STD_ITERATOR_TRAITS */
                                   >
          color_map(color_vec.begin(), color_vec.size(), index_map1);
        record_dfs_order dfs_visitor(dfs_vertices, ordered_edges);
        typedef color_traits<default_color_type> Color;
        for (vertex_iter u = V_mult.begin(); u != V_mult.end(); ++u) {
          if (color_map[*u] == Color::white()) {
            dfs_visitor.start_vertex(*u, G1);
            depth_first_visit(G1, *u, dfs_visitor, color_map);
          }
        }
        // Create the dfs_num array and dfs_num_map
        dfs_num_vec.resize(num_vertices(G1));
        dfs_num = make_safe_iterator_property_map(dfs_num_vec.begin(),
                                                  dfs_num_vec.size(), 
                                                  index_map1
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
                                                  , dfs_num_vec.front()
#endif /* BOOST_NO_STD_ITERATOR_TRAITS */
                                                  );
        size_type n = 0;
        for (vertex_iter v = dfs_vertices.begin(); v != dfs_vertices.end(); ++v)
          dfs_num[*v] = n++;
        
        sort(ordered_edges, edge_cmp(G1, dfs_num));
        
    
        int dfs_num_k = -1;
        return this->match(ordered_edges.begin(), dfs_num_k);
      }