<p>A new version of <a target="_blank" rel="nofollow" href="http://dahtah.github.io/imager/">imager</a> is now available on CRAN. This release brings a lot of new features, including a whole new set of functions dealing with pixel sets, better support for videos, new and faster reduction functions.</p>
<p>The most significant change is the introduction of a “pixset” class, which deals with sets of pixels (for instance, the set of all pixels with a certain brightness, the foreground, the left-hand side of an image, an ROI, etc.). The pixset class includes many tools for working with pixsets, described in a new <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/imager/vignettes/pixsets.html">vignette</a>.</p>
<p><span></span></p>
<p>The following piece of code illustrates some of the new features. We take a picture of coins on a table (from scikit-image), segment the coins from the background and highlight the largest coin:</p>
<pre>
library(imager)
library(dplyr)
im &lt;- load.example(&quot;coins&quot;)
d &lt;- as.data.frame(im)
##Subsamble, fit a linear model to remove trend in illumination, threshold
px &lt;- sample_n(d,1e4) %>% lm(value ~ x*y,data=.)  %>%
    predict(d) %>% { im - . } %>% threshold

##Clean up
px &lt;- clean(px,3) %>% imager::fill(7) 
plot(im)
highlight(px)

## Split into connected components (individual coins)
pxs &lt;- split_connected(px)
## Compute their respective area
area &lt;- sapply(pxs,sum)
## Highlight largest coin in green
highlight(pxs[[which.max(area)]],col=&quot;green&quot;,lwd=2)
</pre>
<p><img sizes="(max-width: 384px) 100vw, 384px" data-image-description="" data-orig-file="https://i1.wp.com/dahtah.files.wordpress.com/2017/03/coins.png?w=456&amp;ssl=1" data-orig-size="384,303" data-image-title="coins" data-comments-opened="1" class="wp-image-420" data-recalc-dims="1" data-attachment-id="420" data-permalink="https://dahtah.wordpress.com/2017/03/15/new-version-of-imager-package-for-image-processing/coins/" alt="" data-medium-file="https://i1.wp.com/dahtah.files.wordpress.com/2017/03/coins.png?w=456&amp;ssl=1?w=300" data-large-file="https://i1.wp.com/dahtah.files.wordpress.com/2017/03/coins.png?w=456&amp;ssl=1?w=384" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i1.wp.com/dahtah.files.wordpress.com/2017/03/coins.png?w=456&ssl=1"></p>
<p>The website’s also been overhauled, and new tutorials are available. These include a tutorial on <a target="_blank" rel="nofollow" href="http://dahtah.github.io/imager/quadtrees.html">quad-trees</a> (using recursive data structures to represent an image), <a>imager as image editor</a> (what’s the equivalent of a circular selection in imager? How about the bucket tool?) , <a target="_blank" rel="nofollow" href="http://dahtah.github.io/imager/unshuffle.html">image unshredding</a> (how to shuffle an image and put it back together).</p>
<p>See <a target="_blank" rel="nofollow" href="http://dahtah.github.io/imager/">here</a> for a complete list.</p>
<p>Below, the full changelog for imager v0.40:</p>
<ul>
<li>added pixset class to represent sets of pixels in an image (implemented as binary images). A test on an image (e.g., im > 0) results in a pixset object. Pixsets come with many convenience functions for plotting, manipulation, morphology, etc. They are described in the &quot;pixsets&quot; vignette.</li>
<li>improved reductions (parmax, parmin, etc.). Most are now implemented in C++ and some run in parallel using OpenMP. A median combine operation (parmedian) has been added.</li>
<li>added load.video, save.video, make.video functions. Loading and saving videos used to be a bit fragile and platform-dependent, it should now be easier and more robust (also slower, sorry). It’s now possible to load individual frames from a video. <em>You still need ffmpeg</em>.</li>
<li>to load images from URLs imager now uses the <em>downloader</em> package, which is more robust than the previous solution</li>
<li>it’s now possible to import images from the raster package and from the magick package.</li>
<li>unified RGB representations so that every function expects RGB values to be in the [0-1] range. There used to be a conflict in expectations here, with R expecting [0-1] and CImg [0-255]. <em>This might break existing code</em> (albeit in minor ways).</li>
<li>new function implot, lets you draw on an image using R’s base graphics.</li>
<li>improved interactive functions for grabbing image regions (grabRect, grabLine, etc.)</li>
<li>improved grayscale conversion</li>
<li>improved plotting. The default is now to have a constant aspect ratio that matches the aspect ratio of the image.</li>
<li>save.image now accepts a quality argument when saving JPEGs.</li>
<li>native support for TIFF, now supports non-integer values in TIFF files</li>
<li>rm.alpha removes alpha channel, flatten.alpha flattens it</li>
<li>imfill now accepts colour names, e.g. <code>imfill(10,10,val='red')</code></li>
<li>improved documentation and examples</li>
<li>added functions for conversion to/from CIELAB</li>
</ul>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dahtah.wordpress.com/412/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/dahtah.wordpress.com/412/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/WDkuPlq_1Jo">