Group Abstract Group Abstract

Message Boards Message Boards

0
|
10K Views
|
13 Replies
|
0 Total Likes
View groups...
Share
Share this post:

DeleteBorder

DeleteBorder increases the size of an image I"m working on by a factor of 7. This seems strange for a function that is supposed to remove image material. Any ideas why this is happening or, more importantly, how to prevent it? Thanks for any insight. Cheers, Scott

POSTED BY: Scott Guthery
13 Replies
POSTED BY: Henrik Schachner

With reiterated thanks to Henrik for his code, I find that one must be careful with ImagePartition as the application of a function to the parts may result in an assembled image that is different than applying the function to the whole (unpartitioned) image.

Here's the unpartitioned code:

pageImage = ColorConvert[pageImage, "Grayscale"];
pageImage = ImageAdjust[pageImage, {2}];
pageImage = ColorToneMapping[pageImage];
pageImage = ImageAdjust[pageImage, {2, -.2, 1.5}];
pageImage = ColorNegate[Binarize[pageImage]];
Print[pageImage];

And here's the partitioned code (via Henrik):

pageImage = ColorConvert[pageImage, "Grayscale"];
partImgs0 = ImagePartition[pageImage, {200}];
partImgs1 = ParallelMap[ColorToneMapping@*ImageAdjust, partImgs0, {2}];
partImgs3 =  ParallelMap[ImageAdjust[#, {2, -.2, 1.5}] &,   partImgs1, {2}]; 
pageImage = ImageAssemble[partImgs3];
pageImage = ColorNegate[Binarize[pageImage]];
Print[pageImage];

See attached for original image and the partitioned and unpartitioned results.

All just FYI.

Cheers, Scott

Attachments:
POSTED BY: Scott Guthery

Hi Scott! Thanks for your nice reply! I hope that my use of @* was not the only reason you made the upgrade. You are right: @* means "composition", but this is not essential here; f@*g is equivalent to f[g[#]]&. But upgrading from v8 to v10 makes a lot of sens anyway! One major innovation is the introduction of Association, which is an improvement when working with large amounts of data (" There is a tsunami of handwritten material being digitized").

Regards -- Henrik

POSTED BY: Henrik Schachner

Henrik ...

Thanks much for your comments and your code. Apologies for the delay in extending my thanks; I had to upgrade from 8 to 10 to understand the code. (Wolfram should credit you with the sale!) Cleaning followed by word extraction is indeed the objective. There is a tsunami of handwritten material being digitized. The time and expense of existing transcription methodologies coupled with declining population skills in cursive mean (IMHO, of course) we have to find new ways searching this material. In passing, I'm curious about the @* notation in line 4, in particular the *. Is this just function composition of some sort?

Thanks again.

Cheers, Scott

POSTED BY: Scott Guthery
POSTED BY: Henrik Schachner

Thanks much, Matthew. Greatly appreciated. And thanks to you too, Eric, for your patience and attention to the matter.

Cheers, Scott

POSTED BY: Scott Guthery
Posted 10 years ago

Nice explanation, Matthew!

POSTED BY: Eric Rimbey
Attachments:
POSTED BY: Matthew Sottile
Posted 10 years ago

Oh, I completely misunderstood.

Hmm, I tried several manipulations of the original image before attempting DeleteBorderComponents (changing the color space, ColorNegate, etc), and every time the result is a completely black image. DeleteBorderComponents doesn't seem to have any options for setting the threshold for what's considered background, which many other image manipulation functions do, so that's kind of weird. This is the first time I've ever tried using DeleteBorderComponents, so I'd have to do some further experimentation before I can speculate on a cause for this behavior with this image. I hope someone else in the community has suggestions. Sorry that I couldn't be more helpful.

POSTED BY: Eric Rimbey

The image is the correct one. The numbers I noted are the number of black pixels in what comes out of ImageData:

pageImage = Import[inputFile];
pageImage=DeleteBorderComponents[pageImage];
binPage = MorphologicalBinarize[pageImage];
Pixels = ImageData[binPage];

In other words, DeleteBorderComponents turns the entire image black (1844 x 3069 = 5659236). Without DeleteBorderComponents there are 750132 black pixels in the image.

Cheers, Scott

POSTED BY: Scott Guthery
Posted 10 years ago

Scott, the jpg you attached seems to have dimensions 1844x3069, which is the size you report for the post DeleteBorderComponents image. Maybe you posted the wrong starting image? Or maybe you just miscalculated the size of the starting image?

POSTED BY: Eric Rimbey

Hello, Eric ...

Here's the code ...

pageImage = Import[inputFile];
pageImage=DeleteBorderComponents[pageImage];

I've attached the image.

Before DeleteBorderComponents I see 750,132 pixels. After DeleteBorderComponents I see 5,659,236.

Thanks in advance for any insight.

Cheers, Scott

Attachments:
POSTED BY: Scott Guthery
Posted 10 years ago

Scott, I'd rather not speculate, so could you post the code and the image you're working with?

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard