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
 layer question
 New Topic  Reply to Topic
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

pierrotsc

USA
497 Posts

Posted - May 11 2020 :  19:57:41  Show Profile  Reply
i extract 3 layers from an rgb image using:
Blue := ImageEnVect_RGB.Proc.GetRGBChannel(iecBlue);
Green := ImageEnVect_RGB.Proc.GetRGBChannel(iecGreen);
Red := ImageEnVect_RGB.Proc.GetRGBChannel(iecRed);

So i get 3 black and white images.
If i modify one channel and want to merge them back to recreate the modified RGB, how would i do that ?

Thanks
Pierre

yogiyang

India
725 Posts

Posted - May 12 2020 :  01:46:20  Show Profile  Reply
Hello,

You are exacting channel data from an Image.

So the best thing to do is to add each channel as layer and set each layers Operation to its respective type like for example: For Layer with red channel data set the operation to TIERenderOperation(ielRed) for green channel to ielGreen and for blue channel to ielBlue.

Now make changes to any channel you want and then merge them into one layer.

I think this will give what you want to achieve.

HTH


Yogi Yang
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 12 2020 :  09:51:26  Show Profile  Reply
Thanks Yogi, but if i use TIERenderOperation(ielRed) for the rd channel, does that gives me a B&W layer ? I am trying to simulate the behavior of photoshop. When you go to channels in photoshop, you get a R,G,B channels that are black and white. When you draw or image process each channel, you do it in B&W but when they are all combined together, you get a color image.
Best
Go to Top of Page

yogiyang

India
725 Posts

Posted - May 13 2020 :  00:55:44  Show Profile  Reply
Hello,

Bu default all channels are in Black & White it is the operation/blending mode that gives it color.

Set the operation to normal and you will get B/W.


Yogi Yang
Go to Top of Page

xequte

38176 Posts

Posted - May 13 2020 :  02:46:12  Show Profile  Reply
Hi

You can use:


procedure SetByRGBChannels(DestBitmap: TIEBitmap; BitmapR, BitmapG, BitmapB: TIEBitmap; fOnProgress: TIEProgressEvent; Sender: TObject);
var
  x, y: Integer;
  sc, rs, gs, bs: pRGB;
  per1: Double;
  bmpW, bmpH: Integer;
begin
  DestBitmap.Allocate(BitmapR.Width, BitmapR.Height, ie24RGB);
  per1 := 100 / DestBitmap.Height;
  bmpH := DestBitmap.height - 1;
  bmpW  := DestBitmap.width - 1;
  for y := 0 to bmpH do
  begin
    sc := DestBitmap.ScanLine[y];
    rs := BitmapR.ScanLine[y];
    gs := BitmapG.ScanLine[y];
    bs := BitmapB.ScanLine[y];
    for x := 0 to bmpW do
    begin
      sc^.r := rs^.r;
      sc^.g := gs^.g;
      sc^.b := bs^.b;
      inc(rs);
      inc(gs);
      inc(bs);
      inc(sc);
    end;
    if assigned(fOnProgress) then
      fOnProgress(Sender, trunc(per1 * y));
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   ImageEnView1.IO.LoadFromFileAuto(ImageEnView1.IO.ExecuteOpenDialog(ExtractFileDir(Application.ExeName), ''));
  ImageEnView1.Proc.GetRGBChannelAll( ievR.IEBitmap, ievG.IEBitmap, ievB.IEBitmap );
  ievR.Update;
  ievG.Update;
  ievB.Update;

  SetByRGBChannels( ImageEnView2.IEBitmap, ievR.IEBitmap, ievG.IEBitmap, ievB.IEBitmap, nil, nil );
  ImageEnView2.Update();
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38176 Posts

Posted - May 13 2020 :  03:51:00  Show Profile  Reply
Hi

Here is a demo showing its usage:

attach/xequte/202051335024_RGBChannels.zip
3,068 KB

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 13 2020 :  08:21:26  Show Profile  Reply
thanks Nigel, exactly what i am looking for but i cannot compile it. some properties are missing so does the SetFromRGBChannels procedure. i guess you are using a more recent imageen. i am running 9.0 trial right now.
oh well.
best
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 13 2020 :  08:25:21  Show Profile  Reply
let me see if i can use the codeyou give me above instead.
thanks
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 13 2020 :  13:58:25  Show Profile  Reply
Nigel, i got it to work. sort of :)
The thing is that i am assigning each channel in imageenlayermview assign to an imageenview. So in the imageenview, i have 3 layers. each layer is a channel. when i click on the channel, it updates the main imageenview. Now when i draw on the imageenview that may be the red channel displayed, it does not really update the channel itself and i cannot figure out on how to find out which channel i am modifying to update the correct one. Am i making sense ? Like if i take your example, i have a source that has 3 layers containing each channel. when i click on the channel, it updates the destination imageenview. but when i draw, i do not draw on the channel itself, i draw on the destination taht is showing the clicked channel.
Any advice to point me in the right direction ?
Best
Go to Top of Page

xequte

38176 Posts

Posted - May 13 2020 :  16:49:12  Show Profile  Reply
I don't really follow you there, a demo might help. When you call SetByRGBChannels (or SetFromRGBChannels in the latest beta), you will need to pass all three bitmaps from the three images in your TImageEnMView, using GetTIEBitmap( n )/ReleaseBitmap( n, False );

https://www.imageen.com/help/TImageEnMView.GetTIEBitmap.html

After editing a channel you will need to assign it back to your TImageEnMView, e.g. using SetImage:

https://www.imageen.com/help/TImageEnMView.SetImage.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 13 2020 :  16:52:38  Show Profile  Reply
Ok, i will look at the help about setimage. but when i move a channel to the main imageenview and modify it, how do i know which channel i have modified, the red, blue or green?

I'll get back to you later on. Got to go now,
let me dig into the help first
Best
Go to Top of Page

xequte

38176 Posts

Posted - May 13 2020 :  17:13:12  Show Profile  Reply
Sorry, I'm not following your workflow. Only you can know which channel is which. To ImageEn all the channels are just grayscale images.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 13 2020 :  21:02:00  Show Profile  Reply
nigel, let me modify your demo tomorrow with my code and you'll see what i am talking about. then you may have a better idea on how to handle it.
best
time to go to bed on the east coast :)
pierre
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 14 2020 :  09:46:29  Show Profile  Reply
Nigel, i have modified your demo. open an rgb image and look on the right at the imageenviewdest. click on each individual channel in the layermview component. Now i want to draw on the imageenviewdest component but i would like the RGB image (Layer 3-background) to get updated.
Best

attach/pierrotsc/20205149449_202051335024_RGBChannels.zip
5.88 KB
Go to Top of Page

xequte

38176 Posts

Posted - May 17 2020 :  04:15:50  Show Profile  Reply
Hi Pierre

Then in the onchange event (delayed so as not to impede performance), call your GetRGBChannel code to update the content of your channel images.

Am I misunderstanding?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 17 2020 :  08:48:01  Show Profile  Reply
maybe, let me ponder on that. i do not see an onchange event, just an onimagechange. not sure about the delayed statement you mentioned too
best
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 17 2020 :  09:23:36  Show Profile  Reply
Ok, when you load my modified demo, you have 2 imaggenview. a source that has 4 layers (red, Blue, green and the RGB). the layermview is assign to the source. Each time you select a layer in the ielayermview, you are selecting either the R,G,B or RGB of the source and assign this layer to the imageenview destination. So the destination has one layer only. it can be a R,G,B or RGB image. I draw on the destination only.
How can i update the RGB layer from the source from the destination layer that has only one layer and you do not know which color is selected ?
Am i making myself clear?
Anyway, just reload my demo and change the mouseinteractgeneral to brushtool to the imageenviewdest. Then draw on it.
Best
Go to Top of Page

yogiyang

India
725 Posts

Posted - May 18 2020 :  00:39:46  Show Profile  Reply
When you click on a layer it automatically get set as CurrentLayer so all that you need to do is update this CurrentLayer in Source from Destination after you have made any modifications to it.

HTH


Yogi Yang
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 18 2020 :  12:14:39  Show Profile  Reply
@yogiyang Thanks for the tip, i think i got it to work but not fully. When i draw on the iamgeenviewdest, it does not update right away. i have to draw again to see the first drawing updated.
I use
ImageEnViewSrc.CurrentLayer.Assign(ImageEnViewDest.CurrentLayer);
ImageEnViewSrc.Update;

Why is the update delayed?
Thanks
Go to Top of Page

xequte

38176 Posts

Posted - May 19 2020 :  15:51:06  Show Profile  Reply
Hi

The update is delayed because at the time you assign the image the painting is still active and has not yet been applied to the image.

Use the on OnUserInteraction and if it's ieiPaintEnd then update ImageEnViewSrc.

https://www.imageen.com/help/TImageEnView.OnUserInteraction.html

OnImageChange should also work, but will get called more often than you need it.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

pierrotsc

USA
497 Posts

Posted - May 19 2020 :  16:18:03  Show Profile  Reply
Thanks Nigel. It worked great. but i guess it would not work with procedure like brightness or contrast and so on.
What should i do when using image processing command.?
Best
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
Jump To: