Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Franchi_S5  
#1 Posted : Friday, March 16, 2018 3:23:59 AM(UTC)
Franchi_S5

Rank: Advanced Member

Groups: Member
Joined: 3/8/2018(UTC)
Posts: 33

Thanks: 15 times
Hi friends,

I´m working in a project where I need cropping images, usually BIG TIFF images.
I´m newbie with this libraries, so I´m reading and reading the documentation, but I can´t find any function to do a auto-deskew (based on edges, or based on text) before apply the crop.

Is there any way to do this...??

Thanks in advance Angel
Fedor  
#2 Posted : Saturday, March 17, 2018 7:15:16 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 post(s)
Hi,

Graphics Mill doesn't implement the deskew algorithm.

The general approach of the algorithm (Hough transform) is described here :

https://stackoverflow.co...05/deskew-scanned-images

I have added your request to our backlog, but we don't have any specific plans to implement it.

If this feature is critical for you please let me know.
Best regards,
Fedor Skvortsov
thanks 1 user thanked Fedor for this useful post.
Franchi_S5 on 3/19/2018(UTC)
Franchi_S5  
#3 Posted : Monday, March 19, 2018 2:51:58 AM(UTC)
Franchi_S5

Rank: Advanced Member

Groups: Member
Joined: 3/8/2018(UTC)
Posts: 33

Thanks: 15 times
Morning Fedor, thanks again.
In my project, I´m trying understand the Pipeline performance and may be I´m doing something wrong.

In this moment I´m trying process a Tiff image. I must crop the input tiff, apply border if selected and write in the output path.

In the next code I´m using Pipeline, if I use the generator I receive an error:
(Either a PipelineElement instance, which cannot act as a receiver, has been passed to a PipelineElement.Receivers collection or a PipelineElement instance, which cannot act as a source, has entries in its PipelineElement.Receivers collection. Nombre del parámetro: element')
And if I don´t use the generator my output image has only 1Kb and it´s a invalid image.
The problem is that I don´t know how to indicate to the blender that the blender.TopImage is the result of the crop operation. I guess this is the cause of my output bad image.
I really don´t know why I don´t need include the reader into my Pipeline sequence (If I do, Pipeline results an exception error saying that TiffReader is included more than one time).
Please, could you help me..?? Thanks in advance.

Code:
using (var reader = TiffReader.Create(ficheroIN))
            using (var crop = new Crop(rectangulo))
            using (var writer = new TiffWriter(ficheroOUT))

            {
                if (procesar_exif)
                {
                    var exif = reader.Exif;
                    writer.Exif = exif;
                }

                if (border_size != 0)
                {
                    using (var borderColor = new RgbColor(0, 0, 0))
                    using (var generator = new ImageGenerator(crop.Rectangle.Width + border_size * 2, crop.Rectangle.Height + border_size * 2, reader.PixelFormat, borderColor))
                    using (var blender = new Blender())
                    {
                        
                        //blender.TopImage = reader;     How do I use as TopImage the crop result  ???
                        blender.X = border_size;
                        blender.Y = border_size;
                        Pipeline.Run(crop + generator + blender + writer);
                    }
                }
                else
                {
                    Pipeline.Run(reader + crop + writer);

                }
            }


Franchi_S5  
#4 Posted : Monday, March 19, 2018 4:47:37 AM(UTC)
Franchi_S5

Rank: Advanced Member

Groups: Member
Joined: 3/8/2018(UTC)
Posts: 33

Thanks: 15 times
I did it on this way, but I don´t know if it´s possible optimize the method including the crop in the Pipeline.
Thanks again.

Code:
using (var reader = TiffReader.Create(ficheroIN))
            using (var crop = new Crop(rectangulo))
            using (var writer = new TiffWriter(ficheroOUT))
            
            {
                var bitmap = new Aurigma.GraphicsMill.Bitmap(rectangulo.Width, rectangulo.Height, reader.PixelFormat);
                if (procesar_exif)
                {
                    var exif = reader.Exif;
                    writer.Exif = exif;
                }

                if (border_size != 0)
                {
                    using (var borderColor = RgbColor.Black)
                    using (var generator = new ImageGenerator(crop.Rectangle.Width + border_size * 2, crop.Rectangle.Height + border_size * 2, reader.PixelFormat, borderColor))
                    using (var blender = new Blender())
                    {
                        bitmap = reader.Frames[0].GetBitmap();
                        bitmap.Transforms.Crop(rectangulo);
                        blender.TopImage = bitmap;
                        blender.X = border_size;
                        blender.Y = border_size;
                        generator.DpiX = reader.DpiX;
                        generator.DpiY = reader.DpiY;
                        Pipeline.Run(generator + blender + writer);
                        bitmap.Dispose();
                    }
                }
                else
                {
                    Pipeline.Run(reader + crop + writer);
                }
            }
Eugene Kosmin  
#5 Posted : Monday, March 19, 2018 11:04:12 PM(UTC)
Eugene Kosmin

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 9/19/2006(UTC)
Posts: 446

Was thanked: 24 time(s) in 24 post(s)
Hi,

This line should do the trick.

Code:
blender.TopImage = reader.Frames[0] + crop;

Best regards,
Eugene Kosmin.
Aurigma Development Team
Franchi_S5  
#6 Posted : Tuesday, March 20, 2018 1:37:08 AM(UTC)
Franchi_S5

Rank: Advanced Member

Groups: Member
Joined: 3/8/2018(UTC)
Posts: 33

Thanks: 15 times
Thanks Eugene, I´ll try it and let you know.

Regards. Angel

Franchi_S5  
#7 Posted : Tuesday, March 20, 2018 2:08:40 AM(UTC)
Franchi_S5

Rank: Advanced Member

Groups: Member
Joined: 3/8/2018(UTC)
Posts: 33

Thanks: 15 times
Originally Posted by: Eugene Kosmin Go to Quoted Post
Hi,

This line should do the trick.

Code:
blender.TopImage = reader.Frames[0] + crop;



It works...!!!! Thanks a lot...!!!
Regards.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.