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
 Mapping Pixels

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
pierrotsc Posted - Jul 31 2013 : 07:44:37
This is more a coding question I need help with. i am trying an efficient way to map pixels.
I am using a grayscale image with 256 shades of gray.
Let's say that i have Zone 0 that have pixels values from 0 to 12 and zone i with values from 13 to 38.

I use imageenview.SelectColors(CreateRGB(0, 0, 0),
CreateRGB(12, 12, 12), iespAdd); to select 0.

Now if i want to map the zone 0 pixels to zone 1 pixels, how would i do that.
For example, pixels 0 should be now 13 and so on.
The thing is that each zone does not have the same number of pixels. So i guess, it would be mapped as a gradient.

I hope some smart coder as an idea on how to achieve that.
Thanks.
P
2   L A T E S T    R E P L I E S    (Newest First)
pierrotsc Posted - Aug 15 2013 : 11:36:56
i found another way by selecting colors and use the cast color to replace the selected pixels.
i'll check your code too.
Thanks.
fab Posted - Aug 15 2013 : 02:43:51
The fastest way (and where you have more control) is to loop among all pixels and map (with a LUT) each pixel to the right value. For example:
const
  MAP: array [0..255] of byte = (
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // zone0: 0..12
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // zone1: 13..38
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // zone2?: ...
    ...etc...
  );
var
  i, j: integer;
  pb: pbyte;
begin
  ImageEnView1.LegacyBitmap := false;
  ImageEnView1.IEBitmap.PixelFormat := ie8g;

  for i := 0 to ImageEnView1.IEBitmap.Height - 1 do
  begin
    pb := ImageEnView1.IEBitmap.ScanLine[i];
    for j := 1 to ImageEnView1.IEBitmap.Width do
    begin
      pb^ := MAP[pb^];
      inc(pb);
    end;
  end;

  ImageEnView1.Update();
end;


You have to fill MAP array with the right desired values. Otherwise you could replace...

pb^ := MAP[pb^];


...with a IF:

if pb^ < 12 then
  pb^ := 0
else if pb^ < 38 then
  pb^ := 1
etc...