Git Product home page Git Product logo

ebimage's Introduction

Installation

The package is distributed as part of the Bioconductor project. To install this package, start R and enter:

install.packages("BiocManager")
BiocManager::install("EBImage")

Documentation

For an overview of the package functionality, see the package vignette.

Once you install the package, you can access individual man pages by a call to, e.g., ?Image.

FAQ

See my answers on Stack Overflow.

Bug reports and feature requests

Bug reports, feature requests, or any other issues with the package should be reported at https://github.com/aoles/EBImage/issues.

ebimage's People

Contributors

aoles avatar dtenenba avatar greg-cotam avatar grimbough avatar hpages avatar jmacdon avatar jwokaty avatar link-ny avatar nturaga avatar vobencha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebimage's Issues

any function to do CLAHE ?

Dear aoles,
Is there any function in this package to do CLAHE (contrast limited adaptive histogram equalization)? I know this following function only doing hist.eq for the whole image.
equalize(x)
Thanks,
Forrest

Only need display and Image

Hello,
I have a pipeline that uses EBImage that was just transferred to a new HPC with little to no infrastructure. The pipeline only uses the display and readImage functions of EBImage. I would like to install EBImage without the fftw dependencies, if at all possible.

Feature request: store file name in Image object

I think it is often useful to be able to check that the image I am currently manipulating actually comes from the file I think it comes from. A quick fileName() would do the trick.

I appreciate that, while probably easy to implement (adding a character slot to the Image class definition), it requires an updateObject to guarantee backwards compatibility. But in case there are other changes in the pipeline, I think this would be useful.

Deploy EBImage to Shinyapps.io

What is the proper way for deploy EBImage to shinyapps.io? Currently, the app works fine locally, and I have the following code at the top of my global.R script:
source("https://bioconductor.org/biocLite.R")
biocLite("EBImage")
library(EBImage)

I thought that would suffice after reading this link, but I'm still having an issue since the app is trying to write to my local directory, and I'm not sure where it should write to when its deployed to shinyapps.io.
rstudio/rsconnect#88

Shinyapps.io Log:
Bioconductor version 3.5 (BiocInstaller 1.26.0), ?biocLite for help
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.5 (BiocInstaller 1.26.0), R 3.4.0 (2017-04-21).
Installing package(s) ‘EBImage’
Error in value[3L] : unable to install packages
Warning in install.packages(pkgs = doing, lib = lib, ...) :
'lib = "/usr/local/lib/R/site-library"' is not writable

I am using EBImage because I needed to use geom_image to display images as my points in a scatterplot. See link below and scroll to the comment at the end for reference.
https://stackoverflow.com/questions/2181902/how-to-use-an-image-as-a-point-in-ggplot

Ask/suggestion Multiple resizing

Hi,

First of all, thanks for sharing this project !

I would like to know if in case of two or more images, the resize function can be applied for each image seperatly ?

For example, imageA (200x200px) and imageB (200x200px) represents two birds, bird B is two times bigger than A. So, we resize only image B (400x400), or inverse image A set to (100x100).

Thanks in advance for your reply,

Sincerely
Luca

floodFill does not work for ND Arrays

Flood fill does not work on 3D arrays. I suggest to either implement it so that it works on ND Arrays or to throw an error.

> x <- array(0, c(4, 4, 4))
+ x[1:2, 1:2, 1:2] <- 1
+ x <- floodFill(x, c(2, 2, 2), 2)
+ 
Warning messages:
1: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
  data length [3] is not a sub-multiple or multiple of the number of columns [2]
2: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
  data length [3] is not a sub-multiple or multiple of the number of columns [2]
3: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
  data length [3] is not a sub-multiple or multiple of the number of columns [2]
4: In matrix(pti, nrow = length(pti)/2, ncol = 2L, byrow = TRUE) :
  data length [3] is not a sub-multiple or multiple of the number of columns [2]
> x
, , 1

     [,1] [,2] [,3] [,4]
[1,]    2    2    0    0
[2,]    2    2    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

, , 2

     [,1] [,2] [,3] [,4]
[1,]    2    2    0    0
[2,]    2    2    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

, , 3

     [,1] [,2] [,3] [,4]
[1,]    2    2    2    2
[2,]    2    2    2    2
[3,]    2    2    2    2
[4,]    2    2    2    2

, , 4

     [,1] [,2] [,3] [,4]
[1,]    2    2    2    2
[2,]    2    2    2    2
[3,]    2    2    2    2
[4,]    2    2    2    2

Where to find EBImage::watershed function code?

Hello,
I am trying to figure out, how EBImage::watershed function works in order to recreate it with python, as it runs pretty slow in R, though is very effective. Is there any technical paper or code available somewhere?

Image subsetting fails when called from Rscript

The following script fails when executed through Rscript. The reason for this is that methods package is not being loaded by Rscript.

library(EBImage)

x = readImage(system.file("images", "sample-color.png", package="EBImage"))
x[1:100, 1:100, ]
Error in slot(x, ".Data") : could not find function "slot"
Calls: [ -> [ -> eval.parent -> eval -> eval
Execution halted

To circumvent this load the methods package through a call to library(methods).

displayOutput hover/click coordinates

Hi,
Just wondering if there is the capability in the shiny binding to get the location of the cursor as with plotOutput:

plotOutput("plot1", click = "plot_click", dblclick = "plot_dblclick", hover = "plot_hover", brush = "plot_brush" ),

Which are then available via input$plot_click etc. I can't see anything in the docs, so maybe this is a feature request?

Check for points out-of-bounds in `floodFill` is incorrect

The check for points out-of-bounds in floodFill (introduced in aefa504) is incorrect and may fail if the image is not square. The problem seems to be that pt>dim(x)[1:2] is computing as.numeric(pt)>dim(x)[1:2] which replicates dim(x) along the columns of pt rather than row-wise.

Here is a snippet which illustrates the problem:

# Points in the image
pt=matrix(c(100, 100, 50, 50), ncol=2)
pt
#>      [,1] [,2]
#> [1,]  100   50
#> [2,]  100   50

# Stand-in for dim(x)[1:2] - x is 200 x 75
dim_x = c(200, 75)

# Checking coordinates individually works fine
any(pt[,1]>dim_x[1])
#> [1] FALSE
any(pt[,2]>dim_x[2])
#> [1] FALSE

# Checking both coordinates at once fails
any(pt>dim_x)
#> [1] TRUE

# 100 > 200 ??
pt>dim_x
#>       [,1]  [,2]
#> [1,] FALSE FALSE
#> [2,]  TRUE FALSE

# The above seems to be equivalent to this:
alt = as.numeric(pt) > dim_x
dim(alt) = dim(pt)
alt
#>       [,1]  [,2]
#> [1,] FALSE FALSE
#> [2,]  TRUE FALSE

Export as.nativeRaster?

I notice the internal function as.nativeRaster() is much faster than as.raster(), especially for larger images, and there are times I would like to call rasterImage() directly, so I can control the plotting parameters that are otherwise set by display() internally.

Would it be possible to export as.nativeRaster() for use by users and from other packages?

3D watershed

Hi @aoles
I'd like watershed to work in 3D (on z-stacks). Right now I can run the function on a stack, but it seems to just perform watershed on each slice individually, rather than really recognizing 3D objects. I think I know how to implement this. Are you interested in receiving a pull-request for this? If so, I'll let you know how I think it should work.
Thanks as always,
Rory

filter2 fails with boundry='replicate' and larger then 3x3 filter

x <- matrix(runif(7*13),7,13)

k <- matrix(1,nrow = 5,ncol = 5);k<-k/sum(k)

x1 <- filter2(x,k,boundary = 'circular')  # This works fine
x2 <- filter2(x,k,boundary = 'replicate') # This has an error

Error in abind(x, duplicate(x, d[1L], 1:d[2L], cf[1L], 1L), duplicate(x, :
arg 'X2' has dims=1, 26; but need dims=X, 13

There is also a problem with the section:

  if ( boundary!="circular" ) {
    y = asub(y, list(1:d[1L], 1:d[2L]), 1:2)
  }

It does not cut out the center image, but top left corner, since indices start at 1 in the list. I have reworked the replicate boundary code a bit to get it to work. Let me know if the code below makes sense and you can use it and please check it on other objects to make sure it works.

# 2D convolution-based linear filter for images and matrix data

# Copyright (c) 2007-2015, Andrzej Oleś, Gregoire Pau, Oleg Sklyar

# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.

# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# See the GNU Lesser General Public License for more details.
# LGPL license wording: http://www.gnu.org/licenses/lgpl.html

## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

filter2_fix = function(x, filter, boundary = c("circular", "replicate")) {
  if ( is.numeric(boundary) ) {
    val = boundary[1L]
    boundary = "linear"
  }
  else
    boundary = match.arg(boundary)
  
  validObject(x)
  validObject(filter)
  
  d = dx = dim(x)
  df = dim(filter)
  dnames = dimnames(x)
  
  if (any(df%%2==0)) stop("dimensions of 'filter' matrix must be odd")
  if (any(dx[1:2]<df)) stop("dimensions of 'x' must be bigger than 'filter'")
  
  cf = df%/%2
  
  switch(boundary,
         ## default mode just wraps around edges
         circular = {},
         ## pad with a given value
         linear = {
           dx[1:2] = dx[1:2] + cf[1:2]
           xpad = array(val, dx)
           ## is there a better way of doing this?
           imageData(x) = do.call("[<-", c(quote(xpad), lapply(d, function(x) enquote(1:x)), quote(x)) )
         },
         replicate = {
           dx[1:2] = dx[1:2] + df[1:2] - 1L

           rep.dim <- function(x,dim,index,times) {
             x.s <- asub(x,idx=index,dims = dim,drop = FALSE)
             dim.s <- dim(x.s)
             dim.s[dim] <- times
             if (dim==2) {
               x.s <- split(x.s,ceiling(seq_along(x.s)/nrow(x)))
               x.s <- sapply(x.s,FUN = rep,times=times)
             } else {
               x.s <- rep(x.s,each=times)
             }
             out <- array(x.s,dim = dim.s)
           }
           
           # Add left and right colums
           lc <- rep.dim(x,2,1,cf[2])
           rc <- rep.dim(x,2,ncol(x),cf[2])
           x <- abind(lc,x,rc,along = 2)
           # Add top and bottom rows
           tr <- rep.dim(x,1,1,cf[1])
           br <- rep.dim(x,1,nrow(x),cf[1])
           imageData(x) <- abind(tr,x,br,along = 1)
         }
  )
  
  ## create fft filter matrix
  wf = matrix(0.0, nrow=dx[1L], ncol=dx[2L])
  
  wf[c(if (cf[1L]>0L) (dx[1L]-cf[1L]+1L):dx[1L] else NULL, 1L:(cf[1L]+1L)), 
     c(if (cf[2L]>0L) (dx[2L]-cf[2L]+1L):dx[2L] else NULL, 1L:(cf[2L]+1L))] = filter
  
  wf = fftw2d(wf)
  
  pdx = prod(dx[1:2])
  
  .filter = function(xx) Re(fftw2d(fftw2d(xx)*wf, inverse=1)/pdx)
  
  ## convert to a frame-based 3D array
  if ( length(dx) > 2L ) {    
    y = apply(x, 3:length(dx), .filter)
    dim(y) = dx
  }
  else {
    y = .filter(x)
  }
  
  if ( boundary!="circular" ) {
    y = asub(y, list(cf[1]+(1:d[1L]), cf[2]+(1:d[2L])), 1:2)
  }
  
  dimnames(y) = dnames
  
  imageData(x) <- y
  x
}

rtiff end of life

(please disregard--this comment actually pertains to an image analysis tutorial that uses EBImage, not the EBImage package itself)

8-connected bwlabels

Hi,

Would it be possible to modify the bwlabels to take into account 8-connected pixels. As far as I can tell, it appears to only take into account 4-connected pixels.

Cheers,
Nick

R Markdown: Error in validImage(x) : object must be an array

If I use R Markdown and I read an image using readImage("lena.png"), I get the following error:

Error in validImage(x) : object must be an array

Everything works perfect if I just use console or R file and it seems to be independent from the image (I tried another one in jpg format). Any idea what the problem could be?

Reduce memory consumption

EBImage requires too much memory to read tiff files containing multiple images even though the images fit comfortably in memory. For example reading a tiff file of size 250x250x1000 requires 6 GB of memory although the resulting EBImage object takes 1.5 GB.
Would it be possible to implement a virtual image stack like in ImageJ? Or at least a form of lazy-loading that only accesses the required subset of the data ?

Preserve subclass in `abind` Image-method

The object returned by abind should be of the same class as inputs. The following should evaluate to TRUE.

ImageSubclass <- setClass ("ImageSubclass", contains = "Image", slots = c(foo = "character"))
x <- ImageSubclass(Image(), foo="bar")

identical(
  class(combine(x, x)),
  class(abind(x, x))
)

## FALSE

Error

Update all/some/none? [a/s/n]:
The console is throwing up this thing.

Question about affine transformation

I am trying out the affine() function with a simple example matrix, and I noticed something that puzzled me. It seems to add an extra row and column to the transformed matrix even if the scaling factors are both 1:

> pre_aff <- matrix( rep( 1, 16 ), nrow = 4 )
> pre_aff
     [,1] [,2] [,3] [,4]
[1,]    1    1    1    1
[2,]    1    1    1    1
[3,]    1    1    1    1
[4,]    1    1    1    1
> mat <- matrix( c( 1, 0, 2, 0, 1, 3 ), nrow = 3 )
> mat
     [,1] [,2]
[1,]    1    0
[2,]    0    1
[3,]    2    3
> affine( pre_aff, mat, output.dim = c( 10, 10 ), antialias = FALSE )
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    0    0    0    0    0    0    0    0    0     0
 [2,]    0    0    1    1    1    1    1    0    0     0
 [3,]    0    0    1    1    1    1    1    0    0     0
 [4,]    0    0    1    1    1    1    1    0    0     0
 [5,]    0    0    1    1    1    1    1    0    0     0
 [6,]    0    0    1    1    1    1    1    0    0     0
 [7,]    0    0    0    0    0    0    0    0    0     0
 [8,]    0    0    0    0    0    0    0    0    0     0
 [9,]    0    0    0    0    0    0    0    0    0     0
[10,]    0    0    0    0    0    0    0    0    0     0

Is this expected behaviour? I thought that the above transformation matrix would simply translate the matrix to a new position but leave the dimensions the same as before the transformation.

Using on-disk array library for @.Data slot?

Hi,

Thanks a lot for this great package. I noticed that most of the memory footprint comes from the data slot which is a base R array.

Every time we do an image operation directly on Image or AnnotatedImage will lead to a full copy of the data and doubles memory usage. For example, let's say we have an Image object img. Then, operations like img * 50 will lead to double of memory usage (even without assign the result to anything!)

Also interestingly, display function will give even more memory usage than double. For example, operations like display(img) will typically give around 200% memory bump for me.

I am assuming that this behavior is caused by the usage of base R array, maybe somewhat mentioned in Issue#40 already.

Could we use on-disk array libraries to replace the current base R array?

For example, HDF5Array seems to be a reasonable replacement. I did a bit research and it seems that 1) it is well-supported by Bioconductor core team, 2) it allows easy conversion of base R array to an on-disk temporary HDF5 array (as simple as hdf5array <- HDF5Array(base.R.array), 3) it chunks the array into small pieces for fast access and only loads the relevant chunks into memory when needed.

Loading Tiff images without scaling

Hello, is there a way to omit scaling grey values to an interval between 0 and 1 when 16-bit Tiff images are loaded with the "readImage" function? This would be very helpful to me. Best regards, Mathias

Unable to determine type Filename extension missing.

I have folder with images
C:/Users/kravchik/Downloads/mypicture
here several image, i need read it.

x <- readImage("C:/Users/kravchik/Downloads/mypicture")

then get the error

Error in readImage("C:/Users/kravchik/Downloads/mypicture") : 
  Unable to determine type of C:/Users/kravchik/Downloads/mypicture: Filename extension missing.

how to read all pictures at once ,
and then extract pixel array for each picture

# width and height of the original image
dim(x)[1:2]

# scale to a specific width and height
y <- resize(x, w = 200, h = 100)

# scale by 50%; the height is determined automatically so that
# the aspect ratio is preserved
y <- resize(x, dim(x)[1]/2)

# show the scaled image
display(y)

# extract the pixel array
z <- imageData(y)

How to do it?

Tolerance setting in watershed

Hello there,

can anyone here please explain to me, what the "tol" setting in the watershed segmentation does?
I have a hard time understanding the description in the package help.

Is this setting like in region-growing, a maximum feature distance between seed point and border pixel on the "ridgeline"? If so, why does it say that:
" If the height is smaller than the tolerance, the object will be combined with one of its neighbors, which is the highest"

That would mean that a pixel whose distance between seed and its own intensity is smaller than the threshold will be assigned to the neighbour?

Many thanks for your help!

Anyway to find out non-overlap, partial-overlap object between two object mask lists

Hi,

Thanks for developing this awesome tool for the image analysis in R. I know there are more tools in Python, but I feel much more comfortable using R to do all the analysis and EBImage saves me!

I have some fluorescence images to do the analysis. I got one list of object masks from the DAPI channel and the other list from the Cy5 channel. I would like to calculate the number of objects that partially overlap between these two lists, as well as the objects without any overlap.

Do you have any suggestions for this particular purpose?

Thanks in advance!

Minjie

Improve documentation

Add sections to the vignette on:

  • image concatenation
  • histogram equalization: equalize and clahe
  • further reading: links to data packages demonstarating aplications of EBImage, e.g. furrowSeg

normalize() does not respect inputRange argument

The result from normalize() does not seem to behave as describe for values handed to the inputRange arguments Here is an example (after loading EBImage_4.18.2):

> x <- matrix(1:9, nrow = 3)
> x <- x/1e3
> x[5] <- 0.1
> x <- Image(x)
imageData(x) # simple "image"
     [,1]  [,2]  [,3]
[1,] 0.001 0.004 0.007
[2,] 0.002 0.100 0.008
[3,] 0.003 0.006 0.009
> round(imageData(normalize(x)), 3) # Expected results
     [,1]  [,2]  [,3]
[1,] 0.00 0.030 0.061
[2,] 0.01 1.000 0.071
[3,] 0.02 0.051 0.081
> xn <- normalize(x, inputRange = c(0, 0.011))
> round(imageData(xn), 3)
     [,1]  [,2]  [,3]
[1,] 0.01 0.040 0.071
[2,] 0.02 1.010 0.081 <-- ???
[3,] 0.03 0.061 0.091

Not only was the value > 0.011 not clipped but it was replaced with a value greater than 1. More extreme values were generated with actual data including images with values ranging from -2 to +5!

(Perhaps not the right place, but thank you very much for creating and maintaining an outstanding set of tools!)

Have some issues with input values for floodfill

I get error while trying to test the result on my data:
Error in EBImage::floodFill(x = matrix(c(rth[10008:10019, 1], rth[10008:10019, :
coordinates 'pt' of the starting point(s) must be inside the image boundaries

I have over 10k points but just cut the snippet to check out if there's really point outside the matrix but could not find what's wrong.

 matrix(c(rth[10008:10019,1], rth[10008:10019,2]), ncol = 2, byrow = F)
          [,1]     [,2]
 [1,] 450689.5 363909.5
 [2,] 450691.5 363909.5
 [3,] 450693.5 363909.5
 [4,] 450695.5 363909.5
 [5,] 450697.5 363909.5
 [6,] 450699.5 363909.5
 [7,] 450701.5 363909.5
 [8,] 450703.5 363909.5
 [9,] 450705.5 363909.5
[10,] 450707.5 363909.5
[11,] 450709.5 363909.5
[12,] 450711.5 363909.5
> c(rth[10010,1], rth[10010,2])
       x        y 
450693.5 363909.5 

My starting point is in 3rd row of the input matrix. Why it's not seen by the function?

Warnings emited by 'readTIFF()' on cells.tiff and nuclei.tiff

As observed across BioC builders (at least malbec1 & malec2).

readImage(system.file('images', 'nuclei.tif', package='EBImage'))

# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file

readImage(system.file('images', 'cells.tif', package='EBImage'))
 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file
# 
# Warning in readTIFF(x, all = all, ...): TIFFFetchNormalTag: ASCII value for
# tag "JPEGTables" does not end in null byte. Forcing it to be null
# 
# Warning in readTIFF(x, all = all, ...): JPEGLib: Premature end of JPEG file

Can the keys that control the keyboard actions be changed when using the display() function?

When you view an image using EBImage::display(), you can view the hotkeys for keyboard actions by pressing "h". Is there a way to change what keys are associated with a certain action?

For example, instead of using < or > to move through frames, or M/? to go to the first or last frame, could one customize these hotkeys? I'm not sure if this can be achieved by editing the javascript file, but I don't want to start digging around without some guidance. Thank you for your time.

Define `abind` method for Image objects

It would be intuitive to have a specialized abind method for Image objects, e.g., to ease up concatenation of images.

Currently there are some problems with S4 methods dispatching on ... which prevent us from turning abind into a generic function. After these have been resolved we could probably have something along the lines:

abind.R

# defined outside of `setMethod` in order to subsequently call `formals` on it
.abind.Image <- function(...) {
  arglist = list(...)
  
  if ( is.list(arglist[[1L]]) ) {
    if ( length(arglist)!=1L )
      stop("can only supply one list-valued arguments for ...")
    arglist <- arglist[[1L]]
  }
  
  cm = colorMode(arglist[[1L]])
  
  if ( !all(cm==vapply(arglist, colorMode, integer(1L), USE.NAMES=FALSE)) )
    stop("images have different color modes")
  
  y <- callNextMethod()
  
  ## don't introduce unnecessary dimnames
  if ( all(vapply(arglist, function(x) is.null(dimnames(x)), logical(1L), USE.NAMES=FALSE)) )
    dimnames(y) <- NULL
  
  Image(y, colormode=cm)
}

# have the same formal arguments as the original function
formals(.abind.Image) <- formals(abind::abind)

setMethod("abind", "Image", .abind.Image)

AllGenerics.R

# explicit signature definition to avoid dispatching on arguments other than `...`
setGeneric("abind", signature="...")

NAMESPACE

## enable abind for Image objects
exportMethods(abind)

normalize is buggy - seems to preserve state

In the example below, normalize works differently after being called without the inputRange argument.

img <- EBImage::readImage(system.file("images", "sample.png", package="EBImage"))

o <- EBImage::normalize(img, inputRange = c(0, 0.05))

p <- EBImage::normalize(img, inputRange = c(0, 0.05))

q <- EBImage::normalize(img)

r <- EBImage::normalize(img, inputRange = c(0, 0.05))

s <- EBImage::normalize(img, inputRange = c(0, 0.05))

data.frame(image = c("o", "p", "q", "r", "s"),
           min = c(min(o), min(p), min(q), min(r), min(s)),
           max = c(max(o), max(p), max(q), max(r), max(s))
           )
#>   image min  max
#> 1     o   0 0.05
#> 2     p   0 0.05
#> 3     q   0 1.00
#> 4     r   0 1.00
#> 5     s   0 1.00

all(o==p)
#> [1] TRUE
all(r==s)
#> [1] TRUE
all(p==r)
#> [1] FALSE
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.1 (2017-06-30)
#>  system   x86_64, darwin15.6.0        
#>  ui       unknown                     
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2017-10-10
#> Packages -----------------------------------------------------------------
#>  package      * version date       source         
#>  abind          1.4-5   2016-07-21 CRAN (R 3.4.1) 
#>  backports      1.1.0   2017-05-22 cran (@1.1.0)  
#>  base         * 3.4.1   2017-08-18 local          
#>  BiocGenerics   0.22.0  2017-10-04 Bioconductor   
#>  compiler       3.4.1   2017-08-18 local          
#>  datasets     * 3.4.1   2017-08-18 local          
#>  devtools       1.13.3  2017-08-02 CRAN (R 3.4.1) 
#>  digest         0.6.12  2017-01-27 CRAN (R 3.4.1) 
#>  EBImage        4.18.2  2017-10-04 Bioconductor   
#>  evaluate       0.10.1  2017-06-24 cran (@0.10.1) 
#>  fftwtools      0.9-8   2017-03-25 CRAN (R 3.4.1) 
#>  graphics     * 3.4.1   2017-08-18 local          
#>  grDevices    * 3.4.1   2017-08-18 local          
#>  grid           3.4.1   2017-08-18 local          
#>  htmltools      0.3.6   2017-04-28 cran (@0.3.6)  
#>  jpeg           0.1-8   2014-01-23 CRAN (R 3.4.1) 
#>  knitr          1.17    2017-08-10 cran (@1.17)   
#>  lattice        0.20-35 2017-03-25 CRAN (R 3.4.1) 
#>  locfit         1.5-9.1 2013-04-20 CRAN (R 3.4.1) 
#>  magrittr       1.5     2014-11-22 cran (@1.5)    
#>  memoise        1.1.0   2017-04-21 CRAN (R 3.4.1) 
#>  methods      * 3.4.1   2017-08-18 local          
#>  parallel       3.4.1   2017-08-18 local          
#>  png            0.1-7   2013-12-03 CRAN (R 3.4.1) 
#>  Rcpp           0.12.13 2017-09-28 cran (@0.12.13)
#>  rmarkdown      1.6     2017-06-15 cran (@1.6)    
#>  rprojroot      1.2     2017-01-16 cran (@1.2)    
#>  stats        * 3.4.1   2017-08-18 local          
#>  stringi        1.1.5   2017-04-07 cran (@1.1.5)  
#>  stringr        1.2.0   2017-02-18 cran (@1.2.0)  
#>  tiff           0.1-5   2013-09-04 CRAN (R 3.4.1) 
#>  tools          3.4.1   2017-08-18 local          
#>  utils        * 3.4.1   2017-08-18 local          
#>  withr          2.0.0   2017-07-28 CRAN (R 3.4.1) 
#>  yaml           2.1.14  2016-11-12 cran (@2.1.14)

floodFill in place

Would it be possible to add a version of floodFill that performs the operation in place?

I have images roughly 1500x1000 to 1800x1400 with hundreds of regions I want to fill with different values. Using EBImage::floodFill, the runtime seems to be dominated by the GC as each fill operation allocates a new copy of the image.

Would it be possible make a version of floodFill that copies the source image only if there are multiple references to it, otherwise modifying it in place?

Deploy in ShinyApp.io with EBImage

I have a problem : i am trying to deploy an app using EBImage on shinyapp.io and I have this error message :
Error: Unhandled Exception: Child Task 726948673 failed: Error building image: Error fetching BiocGenerics (0.35.1) source. Error downloading package source. Please update your BioConductor packages to the latest version and try again: <BioconductorPackageSource
In addition: Warning message:
Error detecting locale: Error in read.table(file = file, header = header, sep = sep, quote = quote, : incomplete final line found by readTableHeader on 'raw'
(Using default: en_US)

So I try to update EBImage using "BiocManager::install()" but it never update it and any time I run this code, it still asks me to update EBImage...
So I tried to update it in developper mode and i have this error message :
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘EBImage’

I am in R version 4.0. Can you help me ?

Improved viewer?

Great package.
I really appreciate the display viewer, but it lacks a slider to adjust contrast & intensity...
A way to save the adjusted image or at least return the scaling factors would also be useful.
Any plans on further improvements?
Thanks!

filter2 not working with n x 1 matrices

Hi,

I am getting an error while running filter2 on a 1-column matrix:
EBImage::filter2(matrix(rnorm(10), ncol = 1), filter = matrix(c(0.25, 0.5, 0.25), ncol = 1))

Error in res[idxRowAppend, nC:2] : subscript out of bounds

There is no problem with a "transposed" (horizontal) call:
EBImage::filter2(matrix(rnorm(10), nrow = 1), filter = matrix(c(0.25, 0.5, 0.25), nrow = 1))

Nor is there a problem with applying a 1-column filter on a multi-dimensional data:
EBImage::filter2(matrix(rnorm(10), ncol = 2), filter = matrix(c(0.25, 0.5, 0.25), ncol = 1))

How to add option to floodFill for diagonal neighbors fill?

I'd like to add option to behave the fill like chess queen, but can't find an option here. Is it there? How much effort to change the code? I tried with floodFill from Rosetta algorithms but there's something not work or maybe I don't understand.

What is the haralick.scales argument to computeFeatures()?

In the documentation, the function computeFeatures has a parameter haralick.scales with a default value of c(1, 2). The parameter is defined as:

A integer vector indicating the number of scales to use to compute the Haralick features.

However, it is not clear what this refers to, even after a brief look at the code https://github.com/aoles/EBImage/blob/master/R/computeFeatures.R#L248.

In the original Haralick paper (Haralick 1973.pdf), the author refers to using both the mean and range of each feature. However, it is not clear if this is related or even an optional output from the algorithm.

Image viewer not shown when running in shiny while not in interactive mode

Hi,
if I run the example from a shiny app run in non-interactive mode the image viewer is not shown.

After struggling a bit I was able to workaround the problem by adding the method parameter to the display call like:

img <- readImage(image_path)
display(img, method = 'browser')

I see that the code in the example is guarded to run only in interactive mode but I think that this behaviour is a bit confusing (other are struggling with this). Wouldn't be nice to add at least a warning message that highlight the behavior?

Thank you very much.

P.S. EBImage is a very nice library thanks for developing it.

Installation error common.h:5:18: fatal error: tiff.h: No such file or directory

I tried to install but failed ##issue:https://gist.github.com/alstat/3bec32e1ad17515d7b3a#gistcomment-1570124
https://stat.ethz.ch/pipermail/r-sig-debian/2012-November/002012.html

$ sudo su - -c "R -e \"biocLite('EBImage')\""               
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> biocLite('EBImage')
Error: could not find function "biocLite"
Execution halted
$ sudo su - -c "R -e \"source('http://bioconductor.org/biocLite.R');biocLite('EBImage')\""

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> source('http://bioconductor.org/biocLite.R');biocLite('EBImage')
Bioconductor version 3.1 (BiocInstaller 1.18.4), ?biocLite for help
BioC_mirror: http://bioconductor.org
Using Bioconductor version 3.1 (BiocInstaller 1.18.4), R version 3.2.1.
Installing package(s) ‘EBImage’
also installing the dependencies ‘tiff’, ‘fftwtools’

trying URL 'http://cran.rstudio.com/src/contrib/tiff_0.1-5.tar.gz'
Content type 'application/x-gzip' length 28925 bytes (28 KB)
==================================================
downloaded 28 KB

trying URL 'http://cran.rstudio.com/src/contrib/fftwtools_0.9-7.tar.gz'
Content type 'application/x-gzip' length 145998 bytes (142 KB)
==================================================
downloaded 142 KB

trying URL 'http://bioconductor.org/packages/3.1/bioc/src/contrib/EBImage_4.10.1.tar.gz'
Content type 'application/x-gzip' length 4117025 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

* installing *source* package ‘tiff’ ...
** package ‘tiff’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c common.c -o common.o
In file included from common.c:1:0:
- common.h:5:18: fatal error: tiff.h: No such file or directory
- #include <tiff.h>
-                   ^
- compilation terminated.
- make: *** [common.o] Error 1
- ERROR: compilation failed for package ‘tiff’
- * removing ‘/usr/lib64/R/library/tiff’
* installing *source* package ‘fftwtools’ ...
** package ‘fftwtools’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c fftwtools.c -o fftwtools.o
- fftwtools.c:28:18: fatal error: fftw3.h: No such file or directory
-  #include<fftw3.h>
-                   ^
- compilation terminated.
- make: *** [fftwtools.o] Error 1
- ERROR: compilation failed for package ‘fftwtools’
- * removing ‘/usr/lib64/R/library/fftwtools’
- ERROR: dependencies ‘tiff’, ‘fftwtools’ are not available for package ‘EBImage’
- * removing ‘/usr/lib64/R/library/EBImage’

The downloaded source packages are in
        ‘/tmp/RtmptJBtDD/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Old packages: 'ggdendro', 'jsonlite', 'networkD3', 'raster', 'shinydashboard',
  'shinyjs', 'sp', 'tidyr', 'VennDiagram'
Warning messages:
- 1: In install.packages(pkgs = doing, lib = lib, ...) :
-  installation of package ‘tiff’ had non-zero exit status
- 2: In install.packages(pkgs = doing, lib = lib, ...) :
-  installation of package ‘fftwtools’ had non-zero exit status
- 3: In install.packages(pkgs = doing, lib = lib, ...) :
-  installation of package ‘EBImage’ had non-zero exit status

install libtiff

$ sudo yum install libtiff
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.i3d.net
 * epel: mirrors.coreix.net
 * extras: mirror.i3d.net
 * updates: mirror.i3d.net
Package libtiff-4.0.3-14.el7.x86_64 already installed and latest version
Nothing to do

install tiffafter check that libtiff-4 has been installed.

$ sudo su - -c "R -e \"install.packages(c('tiff'), dep=TRUE, repos='http://cran.rstudio.com')\""

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages(c('tiff'), dep=TRUE, repos='http://cran.rstudio.com')
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/tiff_0.1-5.tar.gz'
Content type 'application/x-gzip' length 28925 bytes (28 KB)
==================================================
downloaded 28 KB

* installing *source* package ‘tiff’ ...
** package ‘tiff’ successfully unpacked and MD5 sums checked
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG  -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c common.c -o common.o
In file included from common.c:1:0:
- common.h:5:18: fatal error: tiff.h: No such file or directory
- #include <tiff.h>
-                   ^
- compilation terminated.
- make: *** [common.o] Error 1
- ERROR: compilation failed for package ‘tiff’
- * removing ‘/usr/lib64/R/library/tiff’

The downloaded source packages are in
        ‘/tmp/RtmpWvPeb0/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
- In install.packages(c("tiff"), dep = TRUE, repos = "http://cran.rstudio.com") :
-   installation of package ‘tiff’ had non-zero exit status

installation error

#install.packages("BiocManager")
BiocManager::install("EBImage")
...
...
installing to /usr/lib/R/library/00LOCK-EBImage/00new/EBImage/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error in namespaceExport(ns, exports) : undefined exports: class AsIs
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed forEBImagein namespaceExport(ns, exports):
 undefined exports: class AsIs
Error: loading failed
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
Error: package or namespace load failed forEBImagein namespaceExport(ns, exports):
 undefined exports: class AsIs
Error: loading failed
Error in namespaceExport(ns, exports) : undefined exports: class AsIs
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
** testing if installed package keeps a record of temporary installation path
* DONE (EBImage)

http://bioconductor.org/packages/devel/bioc/vignettes/EBImage/inst/doc/EBImage-introduction.html

✓ [master*]> library(EBImage)
ℹ EBImage not installed. Trying to install now
Install 'aoles/EBImage'? (Y/N): 
R-project: EBImage (Documents/GitHub/EBImage)
Y
...
...
...
installing to /usr/lib/R/library/00LOCK-EBImage/00new/EBImage/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error in namespaceExport(ns, exports) : undefined exports: class AsIs
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed forEBImagein namespaceExport(ns, exports):
 undefined exports: class AsIs
Error: loading failed
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
Error: package or namespace load failed forEBImagein namespaceExport(ns, exports):
 undefined exports: class AsIs
Error: loading failed
Error in namespaceExport(ns, exports) : undefined exports: class AsIs
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace -> namespaceExport
** testing if installed package keeps a record of temporary installation path
* DONE (EBImage)
Error: package or namespace load failed for 'EBImage' in namespaceExport(ns, exports):
 undefined exports: class AsIs
✓ [master*]> BBmisc::lib('EBImage')
Loading required package: EBImage
Error: package or namespace load failed for 'EBImage' in namespaceExport(ns, exports):
 undefined exports: class AsIs
Installing package into '/usr/lib/R/library'
(as 'lib' is unspecified)
Loading required package: EBImage
Error: package or namespace load failed for 'EBImage' in namespaceExport(ns, exports):
 undefined exports: class AsIs
Warning message:
package 'EBImage' is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 
EBImage 
  FALSE

ropensci/magick#320 (comment) doesn't help...

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.