ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnView to Matrix
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

pabloabl

4 Posts

Posted - Sep 12 2014 :  07:48:32  Show Profile  Reply
hi,
I need to spend an image from a TImageEnView on three different matrix, red, green and blue.

Before ImageEn I used to do

  for (y = 0; y < image->Picture->Bitmap->Height; y++)
{
p = (byte *) image->Picture->Bitmap->ScanLine[y];
for (x = 0; x < hValues; x++)
{
contadorColores++;
if(contadorColores == 1){
imagenB2[y][contadorB++]=p[x];
}
if(contadorColores == 2){
imagenG2[y][contadorG++]=p[x];
}
if(contadorColores == 3){

imagenR2[y][contadorR++]=p[x];
}
// auximage2[y][x]=p[x];
if(contadorColores==3){
contadorColores=0;
}
}
contadorR=0;
contadorG=0;
contadorB=0;

}

But now do not know how to ImageEnView1.

Thank you very much for your help.

Thanks and best regards.
Pablo.

spetric

Croatia
308 Posts

Posted - Sep 12 2014 :  11:34:20  Show Profile  Reply
Hi,

So you need to separate RGB channels into three different offscreen bitmaps?
There is a method in TImageEnProc component:

GetRGBChannelAll(BitmapR,BitmapG,BitmapB:TIEBitmap);

Which will separate RGB channels from your original bitmap into 3 bitmaps.
I didn't use this method, but I assume that BitmapR, BitmapG and BitmapB
are 8-bit bitmaps.


// let's assume that your original bitmap in some ImageEnView is 24-bit bitmap.
TIEBitmap *bitmapR, *bitmapG, *bitmapB;
bitmapR = new TIEBitmap();
bitmapG = new TIEBitmap();
bitmapB = new TIEBitmap();

bitmapR->PixelFormat = bitmapG->PixelFormat = bitmapB->PixelFormat = ie8g;
// I'll set width and height, although I think it's not necessary,
// but in any case:
bitmapR->Width  = bitmapG->Width = bitmapB->Width = ImageEnView->IEBitmap->Width;
bitmapR->Height = bitmapG->Height = bitmapB->Height = ImageEnView->IEBitmap->Height;

ImageView->Proc->GetRGBChannelAll(BitmapR, BitmapG, BitmapB);



Alternative approach is to scan through ImageEnView->IEBitmap channels.
The same way you've done it, but instead of:

for (y = 0; y < image->Picture->Bitmap->Height; y++)
     {
     p = (byte *) image->Picture->Bitmap->ScanLine[y];
     ...etc... 

You have:

for (y = 0; y < ImageEnView->IEBitmap->Height; y++)
     {
     p = (byte *) ImageEnView->IEBitmap->ScanLine[y];
     ...etc... 



Go to Top of Page

pabloabl

4 Posts

Posted - Sep 14 2014 :  17:31:49  Show Profile  Reply
Hi, thank you very much for answering

I did this to solve the problem, which you think is better?

Graphics::TBitmap *Imagen=new Graphics::TBitmap;

Imagen->Assign(ventanita->ImageEnView1->Bitmap);

int contadorColores = 0;
int contadorR=0, contadorG=0, contadorB=0;
int x, y;
Byte *p;

int hValues; //Number of values the image have in each line (3 x width for colour images)

if(Imagen->PixelFormat==pf24bit)
hValues = 3*Imagen->Width;
else
hValues = Imagen->Width;


for (y = 0; y < Imagen->Height; y++)
{
p = (byte *) Imagen->ScanLine[y];
for (x = 0; x < hValues; x++)
{
contadorColores++;
if(contadorColores == 1){

blue[x] = p[x];
}
}
if(contadorColores == 2){
green[x] = p[x];
}
if(contadorColores == 3){
red[x] = p[x];
}

if(contadorColores==3){
contadorColores=0;
}
}
contadorR=0;
contadorG=0;
contadorB=0;

}

ventanita->ImageEnView1->Assign(Imagen);
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Sep 15 2014 :  00:22:36  Show Profile  Reply
You don't need to assign a new TBitmap image from TIEBitmap (or TBitmap).
You can scan through TIEBitmap the same way as with TBitmap in order to fill
your arrays (matrices).

So instead of using:

Graphics::TBitmap *Imagen=new Graphics::TBitmap;
Imagen->Assign(ventanita->ImageEnView1->Bitmap);


You can simply use ventanita->ImageEnView1->IEBitmap instead.
So, not to change your code too much it would be:


TIEBitmap *Imagen = ventanita->ImageEnView1->IEBitmap;
// You can use TBitmap as well, but I recommend using TIEBitmap
// the rest of code is the same...


Of course, you can use TBitmap intead of TIEBitmap in ImageEnView (see LegacyBitmap parameter), but I recommend using TIEBitmap. You can access pixels in the same way as with TBitmap and TIEBitmap gives you much more methods and options for image manipulation then TBitmap.




Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: