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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEnView to Matrix

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
pabloabl Posted - Sep 12 2014 : 07:48:32
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.
3   L A T E S T    R E P L I E S    (Newest First)
spetric Posted - Sep 15 2014 : 00:22:36
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.




pabloabl Posted - Sep 14 2014 : 17:31:49
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);
spetric Posted - Sep 12 2014 : 11:34:20
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...