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
 Histogram question(s)
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spetric

Croatia
308 Posts

Posted - Mar 18 2015 :  09:25:12  Show Profile  Reply
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


xequte

38505 Posts

Posted - Mar 18 2015 :  20:27:58  Show Profile  Reply
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
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Mar 19 2015 :  18:15:00  Show Profile  Reply
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



Go to Top of Page

xequte

38505 Posts

Posted - Mar 19 2015 :  19:38:18  Show Profile  Reply
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
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Mar 20 2015 :  07:24:43  Show Profile  Reply
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
Go to Top of Page

xequte

38505 Posts

Posted - Mar 20 2015 :  19:36:57  Show Profile  Reply
Nice one!

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: