unable to use RGB values from raster cube data

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

unable to use RGB values from raster cube data

Pratik Anand
Hello everyone,

I am a GSoC student for Opticks working over photography processing tools
as for the first week,

I am creating a plugin for automatic white correction of images.
 For that I am using a simple algorithm:
 finding pixel closest to white in the image i.e. one having max(r+g+b)
 and increase it to (255,255,255) and
proportionately increase other pixels's r,g and b values.


for that I will need access to r,g and b values from raster cube data. I am unable to find a way (through api docs) to do so.

I know that the raster cube I am using ,has the data of the 3 bands (probably as vector) as RasterDataDescriptors::getBandCount() returns 3 as number of bands. But I am unable to find a way to use them or find a specific function that does so. I am even unable to test other functions because of their requirement of DimensionDescriptor whose usage i am yet to find out.



--
Pratik Anand
B.Tech - CSE (3rd year)

http://www.pratikanand.com

Twitter: twitter.com/pratikone
irc nick: pratikone


------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs
Reply | Threaded
Open this post in threaded view
|

Re: unable to use RGB values from raster cube data

Kip Streithorst
Administrator

Pratik,

 

The bands are numbered starting from 0, so to get access to the third band, you could use the following code:

 

void testfunc(RasterElement* pRaster)

{

   RasterDataDescriptor* pDesc = dynamic_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor());

   DimensionDescriptor thirdBand = pDesc->getActiveBand(2);

 

   FactoryResource<DataRequest> pRequest;

   pRequest->setInterleaveFormat(BSQ);

   pRequest->setBands(thirdBand, thirdBand);

 

   DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());

   for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)

   {

      for (unsigned int curCol = 0; curCol < pDesc->getColumnCount(); ++curCol)

      {

          double pixelVal = thirdBandDa->getColumnDataAsDouble();

          thirdBandDa->nextColumn();

      }

      thirdBandDa->nextRow();

   }

}

 

If you want a different band, pass a different number to the pDesc->getActiveBand() call.  Hope this helps.

 

Thanks,

Kip

 

From: Pratik Anand [mailto:[hidden email]]
Sent: Sunday, May 29, 2011 5:11 PM
To: [hidden email]
Subject: [Opticks-devs] unable to use RGB values from raster cube data

 

Hello everyone,

I am a GSoC student for Opticks working over photography processing tools
as for the first week,

I am creating a plugin for automatic white correction of images.
 For that I am using a simple algorithm:
 finding pixel closest to white in the image i.e. one having max(r+g+b)
 and increase it to (255,255,255) and
proportionately increase other pixels's r,g and b values.


for that I will need access to r,g and b values from raster cube data. I am unable to find a way (through api docs) to do so.

I know that the raster cube I am using ,has the data of the 3 bands (probably as vector) as RasterDataDescriptors::getBandCount() returns 3 as number of bands. But I am unable to find a way to use them or find a specific function that does so. I am even unable to test other functions because of their requirement of DimensionDescriptor whose usage i am yet to find out.



--
Pratik Anand
B.Tech - CSE (3rd year)

http://www.pratikanand.com

Twitter: twitter.com/pratikone

irc nick: pratikone

 


This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Opticks-devs mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/opticks-devs