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
 User Demos and Apps
 New Topic  Reply to Topic
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 8

mastinf

Italy
27 Posts

Posted - Feb 11 2016 :  03:41:16  Show Profile  Reply
This demo shows how to create a scan preview form with frame selection.

Download: www.imageen.com/files/other/Scan_Selection.zip

Roberto Nicchi
Master Informatica
Italy
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 11 2016 :  15:46:50  Show Profile  Reply
Besides midpoint, I have implemented another algorithm (trigonometric/general ellipse), so you can switch
between those two algorithms in any time to see the difference.
With trigonometric/ general ellipse method, polyline is less jagged, because of floating point (double) calculation of output points. If there is an interest, I can upload the updated version.

Siniša
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 15 2016 :  08:13:27  Show Profile  Reply
I was experimenting with image energy and min-energy seams and this came out as a by-product. Original article: http://perso.crans.org/frenoy/matlab2012/seamcarving.pdf

Seam carving (content aware scaling).

original image:


scaled (by x):


Exe and source code:

attach/spetric/20162158835_seam_carving.zip
2992.39 KB

Note1: I put black pixels on image border after scaling, however, real stuff is to use alpha channel and fill with zeros.
Note2: seam carver class is threaded.
Note3: There is no backward scaling, because it requires rescaling from beginning, or saving seams into some undo buffer (index maps in article).
Note4: enlarging image is not implemented, (it actually should add seams and fill it with average pixel value left+right/2 in case of horizontal scaling).
Note5: There is no object protection, but it's not hard to implement:we can put a high energy value for pixels in selection mask.
Note6: To force object removal, we put negative energy values for pixels in selection mask.
Note7: To preprocess seams indexing, as suggested by article, we can use idle time in application, and start a thread immediately after image is loaded to create index maps.
Go to Top of Page

xequte

6332 Posts

Posted - Feb 15 2016 :  17:30:38  Show Profile  Reply
Wow, it's impressive how much the seam can be reduced without noticably affecting the subject.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 17 2016 :  16:12:26  Show Profile  Reply
Yes, very cool algorithm, but a little bit slow.
There are some modifications that trades precision vs. speed.

Original algorithm removes seam by seam, but there are some implementations
that calculate all possible 0 connected min seams on original image
and then perform seam removal (this is also suggested in article's appendix).

I have modified prog. a bit (there were also some bugs in energy calculation) and created separate threads for horizontal and vertical seams calculation without removal. Threads are collecting seams and real removal (and restore) is much faster.

However, I have a problem when there is simultaneous horizontal and vertical resizing...I need to create a new map to resolve vertical/horizontal seams crossing. I'll also try an approach with 0 connected seams.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 21 2016 :  10:41:50  Show Profile  Reply
TIEFileDragDrop To TImageEnMView Demo
by William Miller/Adirondack
Full Source
Compiled with Delphi Seattle, but is expected to compile with Delphi 2010 or higher.
Price: Free


The TIEFileDragDrop To TImageEnMView Demo shows how to drag and drop images from the windows shell (File Explorer) to TImageEnMView.

TIEFileDragDrop is not documented for use with TImageEnMView so a brief overview is shown below:

Create a AFileDrop: TIEFileDragDrop; declaration.
AFileDrop: TIEFileDragDrop;

Create a TIEFileDragDrop class in FormCreate:
AFileDrop := TIEFileDragDrop.Create(ImageEnMView1, DropFiles);
Create a Private declaration DropFiles method
procedure DropFiles(Sender: TObject; ssFiles: TStrings; dwEffect: Integer);
Do not explicitly free the AFileDrop object so register a expected memory leak in FormCreate:
RegisterExpectedMemoryLeak(AFileDrop);
Activate dropping in FormCreate:
AFileDrop.ActivateDropping := True;

Download: attach/w2m/2016321105225_TIEFileDragDrop.zip
122.91 KB

Note: Some exception logging Delphi add on's like EurekaLog may show a memory leak even after registering the memory leak, but this is a false positive according to the developers of ImageEn:

"It is best to the let the application handle the freeing of TIEFileDragDrop. Of course then you will get a warning from your memory management tool so you need to register the expected leak (not that it is actually a leak. The object exists for the time of the application and is destroyed when the owner is destroyed).", Nigel Cross

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 29 2016 :  12:06:13  Show Profile  Reply
Fast Brush Painting With IEBitmap Canvas And Alpha Channel Demo
by William Miller/Adirondack
Full Source
Compiled with Delphi Seattle, but is expected to compile with Delphi 2010 or higher.
Price: Free

This demo shows how to do fast "brush" painting with IEBitmap, AlphaChannel and GDICanvas. The demo does not use a traditional "brush". Previous brush drawing demos using GDIPlus all exhibiit slow brush painting that produce intermittent gaps when painting because of the inherent slow speed of TIECanvas drawing speed. This technique has been optimized as much as possible and produces very fast drawing with a smooth continuous brush that can be used for things such as signing signatures on documents, filling information on forms or basic brush painting.

Download: attach/w2m/201632912942_PaintBrush.zip
62.74 KB

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

spetric

Croatia
308 Posts

Posted - May 06 2016 :  07:55:59  Show Profile  Reply
Scale Invariant Feature Transform (C++ XE5)

Implementation is done using FastSift console application:
https://sourceforge.net/projects/libsift/

1. Load source (template) image.
2. Calculate source SIFT key features*.
3. Load target image.
4. Calculate target SIFT key features*.
5. Calculate source/target matching.
6. Adjust distance threshold.

* = if source/target key features are not calculated they will be calculated
in step 5.

Note: matching algorithm is little bit naive: O(n^2). Faster approach is to implement k-d tree algorithm: O(n*log(n)).
https://github.com/jtsiomb/kdtree

Figure 1: source image key features. Each circle radius depends on feature scale



Figure 2: matching lines between source and target images with given threshold




Binaries and source code:

attach/spetric/20165675412_ien_sift.zip
3062.74 KB

Note: any suggestions and prog. corrections are welcomed.
Thanks.

Edit: console program requires grayscale pgm image for calculation.
Program IenSift accepts 24-bit images, which are converted to grayscale and saved as pgm (source.pgm, target.pgm). IenSift invokes console program and
it calculates key features/descriptors and saves them in respectable .kds files. Files (.kds) are parsed and structure (record) is filled with key/descriptor data.

Go to Top of Page

xequte

6332 Posts

Posted - May 08 2016 :  14:21:35  Show Profile  Reply
Hi Spectric

I may be misunderstanding the process, but I couldn't get it to work with the attached...

attach/xequte/201658141845_16-250514202424.jpg
attach/xequte/201658141949_TEST_SRC2.jpg



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - May 09 2016 :  01:39:01  Show Profile  Reply
Hi Nigel,

Maybe it's a bug in demo program. On my side it works Ok.



Here are steps for this test:

1. start IenSift.exe
2. Load source image
3. Load target image
4. Click button "Calc. source/target matching"
5. Adjust threshold slider to 0.5

If it does not work, the problem is probably in paths inside the prog.
I will test the demo in clean virtual Windows Xp/7 to see if it works correctly.

EDIT: Got it! It does not work on clean Win xp/7 machines:

Dependent Assembly Microsoft.VC80.OpenMP,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053" could not be found.

Console app requires MS Visual C++ redistributable package. As I do have MSVC redistributable package on my PC it worked correctly. More precisely, it requires (VC80) Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package.

In "fast sift" description clearly stands: "A cross-platform library that computes fast and accurate SIFT image features. libsiftfast provides Octave/Matlab scripts, a command line interface, and a python interface (siftfastpy). Optimized with SIMD instructions and OpenMP.

I thought that an author packed OpenMP APIs in siftfast.dll, but I was utterly wrong...what a pity. Too much dependencies.



Go to Top of Page

xequte

6332 Posts

Posted - May 09 2016 :  02:57:10  Show Profile  Reply
Hi

Yes, that's what I tried, so I suspect it is related to it looking for the two associated files in a specific path.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - May 09 2016 :  04:04:12  Show Profile  Reply
Hi Nigel,

I have put the answer to the problem in my previous post. The problem is in console application dependencies, which I overlooked.

When I tried it on clean Win xp and 7 installation, the number of detected key-points was 0, which led to console app., that led to MSVC redistributable package dependencies.

It seams that using ready-made console app was not a bright idea, although the app/library is highly optimized.

Edit: I've found a decent source code in plane ANSI C (w/o external dependencies). I'll try to implement it in XE5.
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 15 2016 :  13:33:35  Show Profile  Reply
Hi Roy,

Do you have a demo of the curves tool that will compile and run with Win64? It needs some changes to work with Win64.

I am using the demo posted at the ImageEn User demos.

Win32
Inc(integer(iRGBArray), SFill);
Win65
Inc(pByte(iRGBArray), SFill);

Plus other procedures need modifications or exceptions are produced.

Also please send me your latest email address.

Thanks,

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 19 2016 :  11:09:04  Show Profile  Reply
Demo - How to use Annotations With TImageEnMView with TImageEnVect
by William Miller/Adirondack
Full Source
Compiled with Delphi Seattle, but is expected to compile with Delphi 2010 or higher. Requires ImageEn Version 6.3.
Includes Source Code and EXE
Price: Free

Frame 1


Frame 2


Frame 3


Print Preview Dialog


Printer Result


This demo may be important for many developers of ImageEn who work with multiframe tiff file with objects. The demo shows one way to use annotations with TImageEnMView with TImageEnVect to load, save, print images and objects. When TImageEnMView.AnnotationsVisible is enabled, TOParams.ImageEnAnnot ImageEn annotations of the image are shown on the thumbnail.

Notes:
- This property has no effect if TImageEnMView.StoreType is ietThumb. It is only supported by ietNormal and ietFastThumb.
- This will slow performance so is only recommended for annotation-specific applications.}

Key code:
ImageEnMView1.AnnotationsVisible := True; { This is important }
 
{ Remove all vectorial objects from TIEImageEnAnnot - Important }
ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].ImageEnAnnot.Clear;
{ Copy vectorial objects from a TImageEnVect object to TImageEnMView - Important }
ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage]
  .ImageEnAnnot.CopyFromTImageEnVect(ImageEnVect);

if ImageEnMView1.MIO.Params[idx].ImageEnAnnot.ObjectsCount <>
  ImageEnVect.ObjectsCount then
{ Copy vectorial objects in TIEImageEnAnnot into the specified TImageEnVect - Important}
ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage]
  .ImageEnAnnot.CopyToTImageEnVect(ImageEnVect);

Download: New Update
attach/w2m/2016519193249_Multiframe.zip
2913.88 KB
This demo gets around the need to copyobjectstoback in order to print the image frames and the objects, which is really a nice feature.

I tested this for a while, but there maybe some bugs so if you have a problem let me know. I did test creating a new multiframe tiff file, loading multiframe tif files with objects, saving the multiframe tiff file, and printing all frames or the selected frame. I also tested the scanning with my scanner.

The only known bug is that objects do not preview at all with some 1-bit tiff files.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

klausdoege

Germany
354 Posts

Posted - Sep 10 2016 :  02:51:31  Show Profile  Reply
Hello spetric,
for spetric/20165675412_ien_sift.zip,
is there a delphi source available ?
And for the 20162158835_seam_carving too ?
Regards
Klaus

Klaus
www.klausdoege.de
Go to Top of Page

xequte

6332 Posts

Posted - Sep 11 2016 :  05:49:58  Show Profile  Reply
Hi Klaus

I'm afraid Spetric only programs in C++

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

klausdoege

Germany
354 Posts

Posted - Sep 12 2016 :  13:00:12  Show Profile  Reply
Hello Nigel,

this is a pity, but in my age I will learn no more C++.

Klaus
www.klausdoege.de
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Oct 07 2016 :  04:51:27  Show Profile  Reply
Hi Klaus,

Sorry for delayed answer (I was really busy last few months).
Regarding SIFT, I have managed to compile source code I found on IPOL journal and it works quite well.
It does not depend on any runtime libraries. I'll do some more testing and after that
I'll create a library (static and DLL) and upload it together with demo program.

So, it will be possible to use it from Delphi.
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Oct 11 2016 :  16:41:19  Show Profile  Reply
Done!

Here is a DLL and demo application described in IPOL Journal:

http://www.ipol.im/pub/art/2012/mmm-oh/

Source code in C is freely available and I wrapped it up in DLL so it can be used from Delphi. All parameters are described in article on link above and all necessary structures and DLL entries are described in Orsa.h header that goes with this DLL.

Demo application and Orsa.dll do not require any obscure runtime libraries.



Usage: first load source (sample) and target (master) image.
Then you can click Calc. source SIFT descriptor, Calc. target SIFT descriptor and then click Calc. source/target matching or you can click immediately Calc. source/target matching and program will first calculate source and target descriptors and then calculate source/target matching.

After source/target matching is calculated, you can click Orsa homography to run RANSAC/ORSA homography estimation.

There are three output images: Panorama, Registered image 1 and Registered image 2 (same as in demo on IPOL jurnal pages). If two input images are of "panoramic" sort they will be stitched together in panorama output.

Here is demo application (with source code) and DLL (without source code, source code is really messy)

attach/spetric/2016101116368_orsa_distrib.zip
6062.58 KB

Known bugs: you can select background color to fill output images (panorama, reg1 and reg2), but method fill in template class does not work correctly, so use either clWhite or clBlack. It's some obscure template class and I need to carefully examine the code.

Note: Input bitmaps must be of type ie24RGB. Alpha channel is not supported, but I'll try to implement it in future.

Note: To call DLL from Delphi you only need to convert Orsa.h header file to Pascal. There are only structs (records) and DLL entry typedefs.

Have fun,
Siniša

Edit1: orsaIntersection structure in Orsa.h gives intersection box, i.e. a box that encloses a part where two images intersect. It's useful if you want to blend images reg1 and reg2 to avoid visible stitches. Intersection box coordinates are based on target image.
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Oct 13 2016 :  16:30:29  Show Profile  Reply
I've tried to call DLL from Delphi, but it crashes, because it's not possible to pass classes (TIEBitmap) across module boundaries, except if
it's linked with dynamic RTL/VCL. In C++ it works flawless.

So, I've modified a DLL and all entries are of the same type. Only arguments
passed are two structures. All images are passed as an array of byte pointers to TIEBitmap scanlines.

Although I'm very clumsy with Delphi, I've managed to make SIFT/ORSA work (hurrah).

Beside that, any reference to VCLs are removed from DLL and it's size shrank to 1.4MB.

So, here is again SIFT/ORSA DLL (2.0) with demo exe in C++ (with source code), but this time with demo program in Delphi (source code only). It can load image (24 bit) and calculate SIFT descriptors.

Orsa.h header file was converted to ORSA.PAS file using Dr.Bob's converter wizard and then adjusted by hand...now this was pain in the....

attach/spetric/2016101316245_orsa_20.zip
3596.59 KB

More experienced Delphi programmers can check Orsa.h vs ORSA.PAS and eventually finish Delphi project that I've started.

Have fun,
Siniša

Once again, output images (panorama, reg1 and reg2) are created the same way as in IPOL online demo. I don't like the way panorama, reg1 and reg2 are created:

output.width = max(source.width, target.width)
output.height = max(source.height, target.height)

and then all output images are translated according to center of the new image, but I didn't want to modify original program. If I decide to make some kind of image stitcher, I'll modify the way output images are created.

Go to Top of Page
Page: of 8 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply to Topic
Jump To: