test_mask.cpp
  1| #include "camellia.h"
  2| 
  3| void cpp_example_mask()
  4| {
  5|     CamImage source,dest,mask;
  6|     CamRLEImage encoded_mask;
  7|     
  8|     // Load picture chess.pgm
  9|     source.load_pgm("resources/chess.pgm");    
 10|     mask.alloc(source.width,source.height);
 11| 
 12|     // Draw a filled circle in mask
 13|     mask.set(0);
 14|     mask.draw_circle(mask.width/2,mask.height/2,50,255);
 15|     mask.fill_color(mask.width/2,mask.height/2,255);
 16| 
 17|     // Encode the mask and associate it to the source image
 18|     mask.encode(encoded_mask);
 19|     source.set_mask(encoded_mask);
 20|     
 21|     // Copy the mask
 22|     encoded_mask.inverse();
 23|     dest=source; // Copies only the mask!
 24| 
 25|     // And then compute a sobel inside
 26|     encoded_mask.inverse();
 27|     source.sobel_v_abs(dest); // Sobel only on the mask 
 28|     
 29|     dest.save_pgm("output/chess_sobel_mask.pgm");
 30| }
 31| 
 32|