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
 Histogram question(s)

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
spetric Posted - Mar 18 2015 : 09:25:12
Hi,

I have a question regarding histogram calculation inside selection.
I'm working on "profile" (x/y) histogram. here is an example:



There are two lines (vertical/horizontal). Lines thickness can vary (from 1 to n). Histogram data under vertical line (selection) are shown on the right while histogram data under horizontal line (selection) are shown on the bottom.

Let's say that line thickness is 1. Then selection under horizontal line is constructed as:


PaintView->Select(0, Y, PaintView->IEBitmap->Width-1, Y + 1);


The question is: what is the thickness of selection, i.e. are pixels used to calculate histogram data under Y line, Y+1 line or both?

Beside that, lines are moved with mouse. As lines are actually iekLine objects with XOR blending (antialias = false), there is a slightly delay in onMouse event:


X = PaintView->CurrentLayer->ConvXScr2Bmp(X);
Y = PaintView->CurrentLayer->ConvYScr2Bmp(Y);
PaintView->ObjTop[_hobjHor]  = Y;
PaintView->ObjLeft[_hobjVert] = X;
// histogram
drawHistoProfile(hpHor, X, Y);
drawHistoProfile(hpVert, X, Y);
pbHistoHor->OnPaint = 0;
pbHistoVert->OnPaint = 0;
pbHistoHor->Repaint();
pbHistoVert->Repaint();
drawHistoHor();
drawHistoVert();
pbHistoHor->OnPaint = pbHistoHorPaint;
pbHistoVert->OnPaint = pbHistoVertPaint;


When part that calculates and draws histogram data is commented, delay still occurs. Can it be avoided somehow?

I know there is a solution to draw XOR lines in IECanvas, but I would rather stick to iekLine objects.

TIA,
Siniša


5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 20 2015 : 19:36:57
Nice one!

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Mar 20 2015 : 07:24:43
Hi Nigel,

There is only one real "cure" for this, a new thread.
I left iekLines objects and moved all calculations and histogram/profile drawings
to separate thread. I have put Sleep(100) inside the thread loop and now it works like a charm and iekLines movement is now synchronized.

Thanks for suggestions,
Siniša
xequte Posted - Mar 19 2015 : 19:38:18
Hi Sinisa

Why not use the ImageEnView1DrawCanvas event to access the canvas after the drawing and output your lines? Of course you will need to invalidate the control with each mouse move (but you shouldn't get a flicker effect).



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Mar 19 2015 : 18:15:00
Hi Nigel,

Besides Histogram XY, I have added Profile XY (cumulated RGBs) and iekLines
delay has increased (more calculation).

So, I've tried to draw two perpendicular XOR lines using IECanvas (MoveTo/LineTo). Lines move instantly. There is no delay whatsoever.

But now I have another problem: as IPL image shares the same IEBitmap scanlines, touching anything through IECanvas property, messes up the thing and IPL throws an error.

The good thing is that I use an old MGL library for graphics primitive drawing (MGL also shares IEBitmap scanlines) and drawing XORed lines will not produce an error. I'll try tomorrow with MGL drawing and let you know the results.

The point is, that iekLines objects are slow for such kins of task, or maybe I'm missing something that can speed up objects/iekLines moving.

With best regards,
Siniša



xequte Posted - Mar 18 2015 : 20:27:58
Hi Siniša

If the histogram is based on the selection used above then it would only return it for the Y line (a 1 pixel wide selection).

You should not calculate the histogram on every mousemove event as that would be too slow, you should delay it for 1/4 a second or so.

For example you could disable then re-enable a TTimer (i.e. reset its timing). On the TTImer event update the histogram.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com