1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
vigra::UInt16Image ROIGenerator::GetROILabel(int width,int height)
{
wxBitmap m_bit(width,height);
bool ok1 = m_bit.IsOk(); // retourne false
{
wxMemoryDC dc(m_bit);
ComponentHandler::type_list & list = m_handler.GetList();
ComponentHandler::type_list::iterator it = list.begin();
int i = 2;
for(; it != list.end(); ++it, ++i)
static_cast<ShapeComponent*>( (*it).get() )->GetShape()->Draw(dc,i,width,height);
}
wxImage im = m_bit.ConvertToImage();
m_roi_labellisee = vigra::UInt16Image(width,height);
unsigned short val;
unsigned char g,b;
unsigned char *ptr = im.GetData();
for(int y=0; y<height; y++)
for(int x=0; x<width; x++)
{
int ind = (y*MAXWIDTH+x)*3;
g = ptr[ind + 1];
b = ptr[ind + 2];
//val = toNumber( wxColour(0,im.GetGreen(x,y),im.GetBlue(x,y)) );
val = toNumber( wxColour(0,g,b ));
if( val == 0 )
m_roi_labellisee(x,y) = 0;
else
m_roi_labellisee(x,y) = val;
}
return m_roi_labellisee;
} |
Partager