Giter VIP home page Giter VIP logo

Comments (12)

jeroen avatar jeroen commented on September 27, 2024

Could you add some example code? What does repage do?

from magick.

ShirinG avatar ShirinG commented on September 27, 2024

It removes/resets the virtual canvas meta-data from the images.

I've read that it solves the solution here: https://www.imagemagick.org/discourse-server/viewtopic.php?t=25961

from magick.

jeroen avatar jeroen commented on September 27, 2024

Do you have an example image/code that I can use to test this?

from magick.

jeroen avatar jeroen commented on September 27, 2024

I also added an magick::image_ocr() wrapper.

from magick.

ShirinG avatar ShirinG commented on September 27, 2024

Sure, this is the image: https://github.com/ShirinG/blog_posts_prep/blob/master/ocr/beispiel_scan.png

And the code:

library(tidyverse)
library(tesseract)
library(magick)

image <- image_read("https://raw.githubusercontent.com/ShirinG/blog_posts_prep/master/ocr/beispiel_scan.png")

image_bearb <- image %>%
  image_scale("x2000") %>%                        # rescale
  image_background("white", flatten = TRUE) %>%   # set background to white
  image_trim() %>%                                # Trim edges that are the background color from the image.
  image_noise() %>%                               # Reduce noise in image using a noise peak elimination filter.
  image_enhance() %>%                             # Enhance image (minimize noise)
  image_normalize() %>%                           # Normalize image (increase contrast by normalizing the pixel values to span the full range of color values).
  image_contrast(sharpen = 1) %>%                 # increase contrast
  image_deskew(treshold = 40)                     # deskew image -> creates negative offset in some scans == error

text_2 <- ocr(image_bearb,
              engine = tesseract(language = "deu"))

from magick.

jeroen avatar jeroen commented on September 27, 2024

Hmm it could actually be a problem with the dictionary. Do you get the same error if you don't set the language parameter?

from magick.

ShirinG avatar ShirinG commented on September 27, 2024

Yes, I do get the same error when I use

text_2 <- ocr(image_bearb)

from magick.

jeroen avatar jeroen commented on September 27, 2024

Hmm I can't reproduce the problem here. But it is probably caused by the fact that I use tiff to get the image from magick to tesseract format but maybe I should change that.

Could you try if the problem disappears when you save as png instead?

image_write(image_bearb, "test.png", format = "png")
tesseract::ocr("test.png", engine = tesseract(language = "deu"))

from magick.

ShirinG avatar ShirinG commented on September 27, 2024

Yeah, this works. So, there is no way to have one consecutive pipeline for the whole analysis?

from magick.

jeroen avatar jeroen commented on September 27, 2024

It will be fixed in the next version.

from magick.

ShirinG avatar ShirinG commented on September 27, 2024

Thank you!

from magick.

jeroen avatar jeroen commented on September 27, 2024

This should be fixed in the new version on CRAN.

Note that the magick package now also has a convenience wrapper for tesseract so you can pipe to image_ocr(language = "deu") without specifically loading the tesseract package.

from magick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.