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
 RGB value scan for each pixel over a selection

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
Dudskoni Posted - Oct 13 2012 : 07:58:16
Folks

Considering that I’ve made a rectangle selection in a image I need to scan each line a put the RGB value in a matrix like this:

[ RGBpixel 1 …. RGBpixeln
….
….
….
…. ]

My intention is to count how many pixel of each color the selection has, e.g. yellow pixels. I suppose I would need to implement a algorithm to make an approximation since I would like to count the yellow pixel (for example) no matter the tone.

Thanks in advance for your help.

Duds
2   L A T E S T    R E P L I E S    (Newest First)
Dudskoni Posted - Oct 18 2012 : 16:33:56
I didn't have the opportunity to try but it seems a very good idea work with hue. Many thanks.
fab Posted - Oct 16 2012 : 01:58:44
Hello,
this code loads a jpeg, select a region (50, 90, 300, 400) and count (and mark) all pixels in the Hue range 22:33, that should be orange-like.
You can remove Selection part to allow user to select using the mouse and the LoadFromFile to process a previously loaded image.
Yellow could be a combination of Hue, Saturation and Luminosity (Val).
Hope this helps.

var
  i, j: integer;
  Hue, Sat, Val: integer;
  orangePixels: integer;
begin
  ImageEnView1.IO.LoadFromFile('input.jpg');
  ImageEnView1.Select(50, 90, 300, 400);  // user can also select using mouse instead of this

  orangePixels := 0;
  ImageEnView1.SelectionBase := iesbBitmap;
  for i:=ImageEnView1.SelY1 to ImageEnView1.SelY2 do
    for j:=ImageEnView1.SelX1 to ImageEnView1.SelX2 do
      if ImageEnView1.IsPointInsideSelection(j, i) then
      begin
        RGB2HSV(ImageEnView1.IEBitmap.Pixels_ie24RGB[j, i], Hue, Sat, Val);
        if (Hue >= 22) and (Hue <= 33) then
        begin
          inc(orangePixels);
          ImageEnView1.IEBitmap.Pixels_ie24RGB[j, i] := CreateRGB(255, 0, 0); // optional: just to mark orange pixels
        end;
      end;

  ShowMessage(Format('Counted %d orange pixels', [orangePixels]));
  ImageEnView1.Update();
end;