You are hereFeed aggregator

Feed aggregator


Fair trade ebooks: how authors could double their royalties without costing their publishers a cent

Cory Doctorow - 2017, March 16 - 05:28


My latest Publishers Weekly column announces the launch-date for my long-planned “Shut Up and Take My Money” ebook platform, which allows traditionally published authors to serve as retailers for their publishers, selling their ebooks direct to their fans and pocketing the 30% that Amazon would usually take, as well as the 25% the publisher gives back to them later in royalties.


I’ll be launching the platform with my next novel, Walkaway, in late April, and gradually rolling out additional features, including a name-your-price system inspired by the Humble Bundle and the Ubuntu payment screen.


Selling your own ebooks means that you can have more than one publisher — say, a UK and a US one — and sell on behalf of both of them, meaning that readers anywhere in the world come to one site to buy their books, and the author takes care of figuring out which publisher gets the payment from that purchase.


It’s all an idea whose time has come! My UK publisher, Head of Zeus, is just launched a very similar initiative for authors who don’t want to host their own stores: BookGrail.


Buying an e-book from a website and sideloading it onto your Kindle will never be as easy as buying it from the Kindle store (though if the world’s governments would take the eminently sensible step of legalizing jailbreaking, someone could develop a product that let Kindles easily access third-party stores on the obvious grounds that if you buy a Kindle, you still have the right to decide whose books you’ll read on it, otherwise you don’t really own that Kindle). But a bookstore operated by an author has an advantage no giant tech platform can offer: a chance to buy your e-books in a way that directly, manifestly benefits the author.

As an author, being my own e-book retailer gets me a lot. It gets me money: once I take the normal 30 percent retail share off the top, and the customary 25 percent royalty from my publisher on the back-end, my royalty is effectively doubled. It gives me a simple, fair way to cut all the other parts of the value-chain in on my success: because this is a regular retail sale, my publishers get their regular share, likewise my agents. And, it gets me up-to-the-second data about who’s buying my books and where.

It also gets me a new audience that no retailer or publisher is targeting: the English-speaking reader outside of the Anglosphere. Travel in Schengen, for example, and you will quickly learn that there are tens of millions of people who speak English as a second (or third, or fourth) language, and nevertheless speak it better than you ever will. Yet there is no reliable way for these English-preferring readers, who value the writer’s original words, unfiltered by translation, to source legal e-books in English.

Amazon and its competitors typically refuse outright to deal with these customers, unable to determine which publisher has the right to sell to them. Most publishing contracts declare these nominally non-English-speaking places to be “open territory” where in theory all of the book’s publishers may compete, but in practice, none of them do.


London Book Fair 2017: Cory Doctorow Unveils His Latest Publishing Experiment—Fair Trade E-Books

[Cory Doctorow/Publishers Weekly]

Categories: Blogs

Preorder my novel Walkaway and get a pocket multitool

Cory Doctorow - 2017, March 15 - 10:29

Tor has produced a multitool to commemorate my forthcoming novel Walkaway, and if you pre-order the book, they’ll send you one! Protip: pre-order from Barnes and Noble and you’ll get a signed copy!


The book has received some humblingly great early notices:

Edward Snowden: Is Doctorow’s fictional Utopia bravely idealistic or bitterly ironic? The answer is in our own hands. A dystopian future is in no way inevitable; Walkaway reminds us that the world we choose to build is the one we’ll inhabit. Technology empowers both the powerful and the powerless, and if we want a world with more liberty and less control, we’re going to have to fight for it.

William Gibson: The darker the hour, the better the moment for a rigorously-imagined utopian fiction. Walkaway is now the best contemporary example I know of, its utopia glimpsed after fascinatingly-extrapolated revolutionary struggle. A wonderful novel: everything we’ve come to expect from Cory Doctorow and more.

Kim Stanley Robinson: Cory Doctorow is one of our most important science fiction writers, because he’s also a public intellectual in the old style: he brings the news and explains it, making clearer the confusions of our wild current moment. His fiction is always the heart of his work, and this is his best book yet, describing vividly the revolutionary beginnings of a new way of being. In a world full of easy dystopias, he writes the hard utopia, and what do you know, his utopia is both more thought-provoking and more fun.

Neal Stephenson: Cory Doctorow has authored the Bhagavad Gita of hacker/maker/burner/open source/git/gnu/wiki/99%/adjunct faculty/Anonymous/shareware/thingiverse/cypherpunk/LGTBQIA*/squatter/upcycling culture and zipped it down into a pretty damned tight techno-thriller with a lot of sex in it.

Yochai Benkler: A beautifully-done utopia, just far enough off normal to be science fiction, and just near enough to the near-plausible, on both the utopian and dystopian elements, to be almost programmatic…a sheer delight.

Kirkus Review: A truly visionary techno-thriller that not only depicts how we might live tomorrow, but asks why we don’t already.

Categories: Blogs

NMR in XXI Century: 30 selected things to do and explore

NMR blog - 2017, March 15 - 05:00

A technologist's view of the many open roads to innovate MR.

Categories: Blogs

Thorarin Bjarnason committed [r165]

AnalyzeNNLS - 2017, March 8 - 18:58

Modified PAR/REC file handling to accommodate V...

Categories: Blogs

Logical indexing

Matlab Image processing blog - 2017, March 7 - 14:01

One of my favorite aspects of MATLAB for image processing is how I can use a binary image to index directly into a grayscale image. The technique is called logical indexing, and I'm going to show you how it works today.

Note: this is an update of a post I originally wrote in 2008.

Let me start with a small example. (As regular readers know, I like to use magic squares for small matrix examples.)

A = magic(5) A = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9

Every MATLAB user is familiar with ordinary matrix indexing notation.

A(2,3) ans = 7

A(2,3) extracts the 2nd row, 3rd column of the matrix A. You can extract more than one row and column at the same time:

A(2:4, 3:5) ans = 7 14 16 13 20 22 19 21 3

When an indexing expression appears on the left-hand side of the equals sign, that's an assigment. You are changing one or more of the values of the variable on the left-hand side.

A(5,5) = 100 A = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 100

Here is a frequently-asked MATLAB question: How do I replace all the NaNs in my matrix B with 0s?

An experienced MATLAB user will immediately answer:

B(isnan(B)) = 0;

For example:

B = rand(3,3); B(2, 2:3) = NaN B = 0.2217 0.3188 0.0855 0.1174 NaN NaN 0.2967 0.5079 0.8010

Replace the NaNs with zeros:

B(isnan(B)) = 0 B = 0.2217 0.3188 0.0855 0.1174 0 0 0.2967 0.5079 0.8010

The expression B(isnan(B)) is an example of logical indexing. Logical indexing is a compact and expressive notation that's very useful for many image processing operations.

Let's talk about the basic rules of logical indexing, and then we'll reexamine the expression B(isnan(B)).

If C and D are matrices, then C(D) is a logical indexing expression if D is a logical matrix.

Logical is one of the fundamental data types for MATLAB arrays. Relational operators, such as == or >, produce logical arrays automatically.

C = hilb(4) C = 1.0000 0.5000 0.3333 0.2500 0.5000 0.3333 0.2500 0.2000 0.3333 0.2500 0.2000 0.1667 0.2500 0.2000 0.1667 0.1429 D = C > 0.4 D = 4×4 logical array 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0

If we use D as an index into C with the expression C(D), then we will extract all the values of C corresponding to nonzero values of D and returns them as a column vector. It is equivalent to C(find(D)).

C(D) ans = 1.0000 0.5000 0.5000

Now we know enough to break down the B(isnan(B)) expression to see how it works.

B = rand(3,3); B(2, 2:3) = NaN; nan_locations = isnan(B) nan_locations = 3×3 logical array 0 0 0 0 1 1 0 0 0 B(nan_locations) ans = NaN NaN B(nan_locations) = 0 B = 0.0292 0.4886 0.4588 0.9289 0 0 0.7303 0.2373 0.5468

Functions in the Image Processing Toolbox, as well as the MATLAB functions imread and imwrite, follow the convention that logical matrices are treated as binary (black and white) images. For example, when you read a 1-bit image file using imread, it returns a logical matrix:

bw = imread('text.png'); whos bw Name Size Bytes Class Attributes bw 256x256 65536 logical

This convention, together with logical indexing, makes it very convenient and expressive to use binary images as pixel masks for extracting or operating on sets of pixels.

Here's an example showing how to use logical indexing to compute the histogram of a subset of image pixels. Specifically, given a grayscale image and a binary segmentation, compute the histogram of just the foreground pixels in the image.

Here's our original image:

I = imread('rice.png'); imshow(I)

Here's a segmentation result (computed and saved earlier), represented as a binary image:

url = 'http://blogs.mathworks.com/images/steve/192/rice_bw.png'; bw = imread(url); imshow(bw)

Now use the segmentation result as a logical index into the original image to extract the foreground pixel values.

foreground_pixels = I(bw); whos foreground_pixels Name Size Bytes Class Attributes foreground_pixels 17597x1 17597 uint8

Finally, compute the histogram of the foreground pixels.

figure imhist(foreground_pixels)

As another example, you could complement the binary image to compute something based on the background pixels.

imhist(I(~bw))

PS. I expect that this will be the last blog post that I write using R2016b. Keep an eye on the downloads page!

\n'); d.write(code_string); // Add copyright line at the bottom if specified. if (copyright.length > 0) { d.writeln(''); d.writeln('%%'); if (copyright.length > 0) { d.writeln('% _' + copyright + '_'); } } d.write('\n'); d.title = title + ' (MATLAB code)'; d.close(); } -->


Get the MATLAB code (requires JavaScript)

Published with MATLAB® R2016b

_. % % Let me start with a small example. (As regular readers know, I like % to use magic squares for small matrix examples.) A = magic(5) %% % Every MATLAB user is familiar with ordinary matrix indexing % notation. A(2,3) %% % |A(2,3)| extracts the 2nd row, 3rd column of the matrix |A|. You % can extract more than one row and column at the same time: A(2:4, 3:5) %% % When an indexing expression appears on the left-hand side of % the equals sign, that's an assigment. You are changing one or more of the % values of the variable on the left-hand side. A(5,5) = 100 %% % Here is a frequently-asked MATLAB question: _How do I replace all the % NaNs in my matrix B with 0s?_ % % An experienced MATLAB user will immediately answer: % % B(isnan(B)) = 0; % % For example: B = rand(3,3); B(2, 2:3) = NaN %% % Replace the NaNs with zeros: B(isnan(B)) = 0 %% % The expression |B(isnan(B))| is an example of _logical indexing_. % Logical indexing is a compact and expressive notation that's very useful % for many image processing operations. % % Let's talk about the basic rules of logical indexing, and then % we'll reexamine the expression |B(isnan(B))|. % % If |C| and |D| are matrices, then |C(D)| is a logical indexing % expression if |D| is a _logical_ matrix. % % _Logical_ is one of the fundamental data types for MATLAB arrays. % Relational operators, such as |==| or |>|, produce logical % arrays automatically. C = hilb(4) %% D = C > 0.4 %% % If we use |D| as an index into |C| with the expression |C(D)|, then we % will extract all the values of |C| corresponding to nonzero values of |D| % and returns them as a column vector. It is equivalent to |C(find(D))|. C(D) %% % Now we know enough to break down the |B(isnan(B))| expression to see % how it works. B = rand(3,3); B(2, 2:3) = NaN; nan_locations = isnan(B) %% B(nan_locations) %% B(nan_locations) = 0 %% % Functions in the Image Processing Toolbox, as well as the % MATLAB functions |imread| and |imwrite|, follow the convention that % logical matrices are treated as binary (black and white) % images. For example, when you read a 1-bit image file using % |imread|, it returns a logical matrix: bw = imread('text.png'); whos bw %% % This convention, together with logical indexing, makes it very % convenient and expressive to use binary images as pixel masks % for extracting or operating on sets of pixels. %% % Here's an example showing how to use logical indexing to % compute the histogram of a subset of image pixels. % Specifically, given a grayscale image and a binary % segmentation, compute the histogram of just the foreground % pixels in the image. % % Here's our original image: I = imread('rice.png'); imshow(I) %% % Here's a segmentation result (computed and saved earlier), % represented as a binary image: url = 'http://blogs.mathworks.com/images/steve/192/rice_bw.png'; bw = imread(url); imshow(bw) %% % Now use the segmentation result as a logical index into the % original image to extract the foreground pixel values. foreground_pixels = I(bw); whos foreground_pixels %% % Finally, compute the histogram of the foreground pixels. figure imhist(foreground_pixels) %% % As another example, you could complement the binary image to compute % something based on the background pixels. imhist(I(~bw)) %% % _PS. I expect that this will be the last blog post that I write using % R2016b. Keep an eye on the _ ##### SOURCE END ##### e286582d3ff74f9f8ff5c3de3b9c3809 -->

Categories: Blogs

Fill Your Boots: my column on how technology could let us work like artisans and live like kings

Cory Doctorow - 2017, March 3 - 06:39

My latest Locus column is “Fill Your Boots,” in which I talk about how scientists, sf writers, economists and environmental activists have wrestled with the question of abundance — how the “green left” transformed left wing politics from the promise of every peasant living like a lord to the promise of every lord living like a peasant.


One thing everyone can agree on is that market competition and technology has made material abundance a lot less material: the labor, energy, and resources in a car, a house, or a shirt are a mere fraction of what they were a couple of generations ago, and continue to fall with no end in sight. Another point of commonality is that computers make it easier to coordinate your work with other people, whether that’s Github providing the scaffold for building out an open source project or Slack giving people scattered all over the world the power to plan a product launch or a birthday party.

The combination of reduced material inputs to goods and cheap coordination presents us with the possibility of a new, better kind of abundance: a world where we leave behind the demands of the assembly line and the anxiety of whether the light-switch will always turn on the lights, for one where we treat sunny days a jubilees, when we can use as much unbankable and infinite solar energy as we want, leaving the doors open and the air conditioners running. It’s the best of both worlds, freeing work from the tyranny of other peoples’ schedules without giving up the fantastic comforts of material abundance.

The limits to labor/energy/material efficiency are speculative. We don’t know what the hard limits are on how little material can go into a car, how little fuel can propel an airplane, or how much of the labor embodied in your house could be performed by robots.

We don’t need to speculate to understand how sweet our lives could be if they were re-tuned to the rhythms of the natural world, if every time the sun shone we stopped having to worry about closing the door, if every time it rained we stopped worrying about whether the toilet really needs flushing, or whether it can mellow for one more yellow.

My next novel, Walkaway, includes an entire subculture called ‘‘the bumblers.’’ These are the survivors of a speculative investment bubble in zeppelins, a global phenomenon that left millions around the world with the knowledge and capacity to build airships, and networks of friends, fellow travellers, and potential couch-surfing hosts all over the world. These sky-hobos go aloft in their minimally steerable zeppelins and literally go wherever the wind blows them, knowing that they will almost certainly meet someone interesting, wherever the zeppelin happens to take them. It’s not jet travel. You can’t decide where you’re going. But if you don’t care where you end up – because all you want is to get somewhere – then bumbling is superior to conventional aviation on every metric.

Here is where the green left and the bright green left can meet: using bright green, high tech coordina­tion tools, we can restore the pastoral green, artisanal autonomy that privileges mindful play over mindless work. The motto of Magpie Killjoy’s Steampunk zine was ‘‘love the machine, hate the factory.’’ Love the dividends of coordinated labor, hate the loss of freedom we suffer when we have to coordinate with others. Have your cake and eat it too.

The Jubilee: Fill Your Boots [Cory Doctorow/Locus Magazine]

Categories: Blogs

Reply All covers DRM and the W3C

Cory Doctorow - 2017, March 2 - 07:45

In the latest episode of Reply All, a fantastic tech podcast, the hosts and producers discuss the situation with DRM, the future of the web, and the W3C — a piece I’ve been working on them with for a year now.


The issue is a complicated and eye-glazingly technical one, and they do a genuinely excellent job presenting the story. Inevitably, there’s some nuance lost in the translation, and so here’s a bit more, for people who are interested.

The story talks about DRM as an anti-piracy technology. I think that’s just wrong, though DRM advocates walk a confusing line on this question. They freely admit that DRM can be broken by skilled attackers, and that dishonest people can just access versions of movies or songs or whatever that the DRM-breakers have stripped the DRM off of (the Reply All host starts off by describing how he hits all kinds of problems with DRM on movies he pays for, leading him to download easy-to-find cracked versions).

So if DRM isn’t anti-piracy, what is it? DRM isn’t really a technology at all, it’s a law. Specifically, it’s section 1201 of the US DMCA (and its international equivalents). Under this law, breaking DRM is a crime with serious consequences (5 years in prison and a $500,000 fine for a first offense), even if you’re doing something that would otherwise be legal. This lets companies treat their commercial strategies as legal obligations: Netflix doesn’t have the legal right to stop you from recording a show to watch later, but they can add DRM that makes it impossible to do so without falling afoul of DMCA.

This is the key: DRM makes it possible for companies to ban all unauthorized conduct, even when we’re talking about using your own property in legal ways. This intrudes on your life in three ways:

1. It lets companies sue and threaten security researchers who find defects in products

2. It lets companies sue and threaten accessibility workers who adapt technology for use by disabled people

3. It lets companies sue and threaten competitors who want to let you do more with your property — get it repaired by independent technicians, buy third-party parts and consumables, or use it in ways that the manufacturer just doesn’t like.

How do we know that companies only want DRM because they want to abuse this law, and not because they want to fight piracy? Because they told us so. At the W3C, we proposed a compromise: companies who participate at W3C would be allowed to use it to make DRM, but would have to promise not to invoke the DMCA in these ways that have nothing to do with piracy. So far, nearly 50 W3C members — everyone from Ethereum to Brave to the Royal National Institute for Bind People to Lawrence Berkeley National Labs — have endorsed this, and all the DRM-supporting members have rejected it.

In effect, these members are saying, “We understand that DRM isn’t very useful for stopping piracy, but that law that lets us sue people who aren’t breaking copyright law? Don’t take that away!”

The Director of the W3C, web inventor Tim Berners-Lee, wrote recently about why he supports DRM standardization, an odd step that it hard to understand, really: the leaders of the DRM standardization committee at the W3C have asked Berners-Lee to consult with his members to ask whether they want to see this DRM standard published. Instead, he appears to be telling us what decision he plans on coming to, regardless of how that consultation goes.

#90 Matt Lieber Goes To Dinner [Reply All/Gimlet]

Categories: Blogs

Coming to DC on March 6: a panel on right to repair, DRM, and property rights in the digital age

Cory Doctorow - 2017, March 1 - 06:09

On Monday, March 6 at 10AM, I’ll be participating in a non-partisan R-Street event on “Property Rights in the Digital Age,” with participants from the Heritage Foundation, R-Street, the Open Technology Institute, and Freedomworks: “As we enter an age near total connectivity, we must ask ourselves, are our laws keeping up with technology? Do we need to rewrite the rules to preserve our traditional notions of property, or embrace the brave new world of licensing everything?” (RSVP)

Categories: Blogs

New Yorkers! Come see Edward Snowden and me onstage at the NYPL on the Walkaway tour!

Cory Doctorow - 2017, February 26 - 12:07

I’m touring 20 US cities (plus dates in Canada and the UK!) with my forthcoming novel Walkaway; the full tour hasn’t been announced yet, but I’m delighted to reveal that the NYC stop on May 3 will be at the New York Public Library, where my interlocutor will be the whistleblower Edward Snowden. Tickets are $10-25! (Reminder: there are also signed first-edition hardcovers available for pre-order in the USA and UK).

Categories: Blogs

Now in the UK! Pre-order signed copies of the first edition hardcover of Walkaway, my first adult novel since Makers

Cory Doctorow - 2017, February 11 - 10:22

The UK’s Forbidden Planet is now offering signed hardcovers of Walkaway, my first novel for adults since 2009 — this is in addition to the signed US hardcovers being sold by Barnes and Noble.

Walkaway has scored starred reviews in Booklist (“memorable and engaging” and “ultimately suffused with hope”) and Kirkus (“A truly visionary techno-thriller that not only depicts how we might live tomorrow, but asks why we don’t already”).

Edward Snowden said the book was “a reminder that the world we choose to build is the one we’ll inhabit” and Kim Stanley Robinson called it “a utopia both more thought-provoking and more fun than a dystopia” and Neal Stephenson called “the Bhagavad Gita of hacker/maker/ burner/open source/git/gnu/wiki/99%/adjunct faculty/Anonymous/shareware/thingiverse/cypherpunk/ LGTBQIA*/squatter/upcycling culture, zipped down into a pretty damned tight techno-thriller with a lot of sex in it.” Yochai Benkler said “A beautifully-done utopia, just far enough off normal to be science
fiction, and just near enough to the near-plausible, on both the
utopian and dystopian elements, to be eerie as almost programmatic…a
sheer delight.”

The book comes out on April 25; I’m touring 20 cities in the USA, plus major Canadian cities and a week-long tour of the UK — details TBA.

Pre-order signed Walkaway in the UK [Forbidden Planet]

Pre-order signed Walkaway in the USA [Barnes and Noble]

Categories: Blogs

Pre-order a signed first edition of Walkaway, which got a starred review in Booklist today!

Cory Doctorow - 2017, February 1 - 14:08

Here’s a reminder that you can pre-order a signed first edition hardcover of Walkaway, my first novel for adults since 2009, which William Gibson called “A wonderful novel” and Edward Snowden called “a reminder that the world we choose to build is the one we’ll inhabit” and Kim Stanley Robinson called “a utopia is both more thought-provoking and more fun than a dystopia” and Neal Stephenson called “the Bhagavad Gita of hacker/maker/burner/open source/git/gnu/wiki/99%/adjunct faculty/Anonymous/shareware/thingiverse/cypherpunk/LGTBQIA*/squatter/upcycling culture, zipped down into a pretty damned tight techno-thriller with a lot of sex in it.”


I signed 2,900 early copies of the first edition, and I’ll be visiting 20 US cities as well as cities across Canada and the UK this spring to read from and discuss the book.

Happily, today’s Booklist contained a starred review by Regina Schroeder, who called it “memorable and engaging” and “ultimately suffused with hope.” This is the book’s second starred review — last December’s Kirkus reviews called it “A truly visionary techno-thriller that not only depicts how we might live tomorrow, but asks why we don’t already.”


The book drops on April 25, and I’m so damned excited I can barely contain myself!

Order your signed copy here.

Categories: Blogs

The cover of this week’s Bookseller!

Cory Doctorow - 2017, January 31 - 07:56

Categories: Blogs

Clarion Workshop now accepting applications for sf writers to learn with Lynda Barry, Nalo Hopkinson, CC Finlay…and me!

Cory Doctorow - 2017, January 30 - 06:53



The instructors for this summer’s Clarion Science Fiction and Fantasy writers’ workshop are Dan Chaon, Lynda Barry, Nalo Hopkinson, Andrea Hairston, Cory Doctorow, C.C. Finlay and Rae Carson: the workshop runs from Jun 25-Aug 5 at UCSD in La Jolla, California.


It’s an intensive, boot-camp style writing workshop that’s been running annually since 1968. New instructors rotate in every week and students write about one story every week, and learn to improve their work by critiquing one another’s stories and having their own work critiqued. Students meet one-on-one with each instructor and take part in special activities, exercises and challenges set by the instructors.


The “distinguished alumni” of the workshop include Ted Chiang, Bruce Sterling, Octavia Butler, James Patrick Kelly, Nalo Hopkinson, Kim Stanley Robinson, Kathe Koja, Eileen Gunn, Tobias Buckell, Gavin Grant, Richard Kadrey and many, many others.

I teach Clarion every two years or so, as part of my “paying forward” — my own Clarion experience in 1992 was absolutely transformative for my writing and my career.

Financial assistance is available.

Application – 2017 Clarion Workshop; Sunday, June 25, 2017 – Saturday, August 05, 2017 [The Clarion Foundation]

Categories: Blogs

Gaussian filtering with imgaussfilt

Matlab Image processing blog - 2017, January 23 - 06:14

With the R2015a release a couple of years ago, the Image Processing Toolbox added the function imgaussfilt. This function performs 2-D Gaussian filtering on images. It features a heuristic that automatically switches between a spatial-domain implementation and a frequency-domain implementation.

I wanted to check out the heuristic and see how well it works on my own computer (a 2015 MacBook Pro).

You can use imgaussfilt this way:

rgb = imread('peppers.png'); sigma = 10; rgb_smoothed = imgaussfilt(rgb,sigma); imshow(rgb) imshow(rgb_smoothed) title('Gaussian smoothed, \sigma = 10')

With this call, imgaussfilt automatically chooses between a spatial-domain or a frequency-domain implementation. But you can also tell imgaussfilt which implementation to use.

rgb_smoothed_s = imgaussfilt(rgb,sigma,'FilterDomain','spatial'); rgb_smoothed_f = imgaussfilt(rgb,sigma,'FilterDomain','frequency');

I'll use this syntax, together with the timeit function, to get rough timing curves for the two implementation methods. The heuristic used by imgaussfilt uses a few different factors to decide, including image size, Gaussian kernel size, single or double precision, and the availability of processor-specific optimizations. For my computer, with a 2000-by-2000 image array, the cross-over point is at about $\sigma = 50$. That is, imgaussfilt uses the spatial-domain method for $\sigma < 50$, and it uses a frequency-domain method for $\sigma > 50$.

Let's check that out with a set of $\sigma$ values ranging from 5 to 200.

I = rand(2000,2000); ww = 5:5:200; for k = 1:length(ww) t_s(k) = timeit(@() imgaussfilt(I,ww(k),'FilterDomain','spatial')); end for k = 1:length(ww) t_f(k) = timeit(@() imgaussfilt(I,ww(k),'FilterDomain','frequency')); end plot(ww,t_s) hold on plot(ww,t_f) hold off legend('spatial','frequency') xlabel('\sigma') ylabel('time (s)') title('imgaussfilt - 2000x2000 image')

As you can see, the cross-over point of the timing curves is about the same as the threshold used by imgaussfilt. As computing hardware and optimized computation libraries evolve over time, though, the ideal cross-over point might change. The Image Processing Toolbox team will need to check this every few years and adjust the heuristic as needed.

\n'); d.write(code_string); // Add copyright line at the bottom if specified. if (copyright.length > 0) { d.writeln(''); d.writeln('%%'); if (copyright.length > 0) { d.writeln('% _' + copyright + '_'); } } d.write('\n'); d.title = title + ' (MATLAB code)'; d.close(); } -->


Get the MATLAB code (requires JavaScript)

Published with MATLAB® R2016b

. This function performs 2-D Gaussian filtering on % images. It features a heuristic that automatically switches % between a spatial-domain implementation and a frequency-domain % implementation. % % I wanted to check out the heuristic and see how well it works on % my own computer (a 2015 MacBook Pro). % % You can use |imgaussfilt| this way: rgb = imread('peppers.png'); sigma = 10; rgb_smoothed = imgaussfilt(rgb,sigma); imshow(rgb) %% imshow(rgb_smoothed) title('Gaussian smoothed, \sigma = 10') %% % With this call, |imgaussfilt| automatically chooses between a % spatial-domain or a frequency-domain implementation. But you can % also tell |imgaussfilt| which implementation to use. rgb_smoothed_s = imgaussfilt(rgb,sigma,'FilterDomain','spatial'); rgb_smoothed_f = imgaussfilt(rgb,sigma,'FilterDomain','frequency'); %% % I'll use this syntax, together with the |timeit| function, to get % rough timing curves for the two implementation methods. % The heuristic used by |imgaussfilt| uses a few different factors % to decide, including image size, Gaussian kernel size, single or % double precision, and the availability of processor-specific % optimizations. For my computer, with a 2000-by-2000 image array, % the cross-over point is at about $\sigma = 50$. That is, % |imgaussfilt| uses the spatial-domain method for $\sigma < 50$, % and it uses a frequency-domain method for $\sigma > 50$. % % Let's check that out with a set of $\sigma$ values ranging from 5 % to 200. I = rand(2000,2000); ww = 5:5:200; for k = 1:length(ww) t_s(k) = timeit(@() imgaussfilt(I,ww(k),'FilterDomain','spatial')); end for k = 1:length(ww) t_f(k) = timeit(@() imgaussfilt(I,ww(k),'FilterDomain','frequency')); end plot(ww,t_s) hold on plot(ww,t_f) hold off legend('spatial','frequency') xlabel('\sigma') ylabel('time (s)') title('imgaussfilt - 2000x2000 image') %% % As you can see, the cross-over point of the timing curves is about % the same as the threshold used by |imgaussfilt|. As computing % hardware and optimized computation libraries evolve over time, % though, the ideal cross-over point might change. The Image % Processing Toolbox team will need to check this every few years % and adjust the heuristic as needed. ##### SOURCE END ##### a8e0fa0a1801485fb08e2add318cf07e -->

Categories: Blogs

Aliasing and image resizing – part 3

Matlab Image processing blog - 2017, January 16 - 09:29

Today I'll try to wrap up my discussion about how aliasing affects image resizing and about how the imresize function tries to prevent it. (This is called antialiasing.) Let me show you where we are going. Here is the zone plate image I showed last time.

Z = imzoneplate(501); imshow(Z) title('Z')

Here's what happens when we shrink Z by throwing away samples.

Z4 = Z(1:4:end,1:4:end); imshow(Z4) title('Z4')

And here's what imresize does (with the default behavior):

Z4_imresize = imresize(Z,0.25); imshow(Z4_imresize) title('imresize(Z,0.25)')

Before I get started describing the imresize approach to antialiasing, I should say that there are several algorithm approaches to antialiasing in image resizing. This is just one. It is based on classical ideas from digital signal processing.

I'll use the notation that $f[n]$ is a function of a discrete variable $n$, and $f(x)$ is a function of a continuous variable $x$. Here's a way to think about the image resizing problem that is theoretically useful. To simplify the discussion for a bit, I'll talk in terms of 1-D signals. (Warning: people with a graduate-level background in digital signal processing will probably find this explanation too hand-wavy. Everybody else will find it too jargon-y. I'm doing my best.)

Suppose we want to convert a 1-D signal, $f[n]$, to another 1-D signal that has a different sampling rate.

  1. Convert the discrete-domain signal, $f[n]$, to a continuous-domain signal, $f(x)$. Theoretically, this step involves the use of a continuous-domain filter, $h(x)$. You can think of this step as a form of interpolation (for some choices of $h(x)$, anyway).
  2. Convert the continuous-domain signal, $f(x)$, to a new discrete-domain signal, $g[n]$, by sampling $f(x)$ at the desired rate: $g[n] = f(nT)$.

There's a problem with the two-step procedure above. If the sampling rate for $g[n]$ is reduced from the original sampling rate of $f[n]$, then the procedure is susceptible to aliasing distortion if $f[n]$ contains high frequencies that cannot be represented at the lower sampling rate. To address this problem, let's insert another step in the procedure.

  1. Convert the discrete-domain signal, $f[n]$, to a continuous-domain signal, $f(x)$.
  2. Pass $f(x)$ through a lowpass filter to remove high-frequency components that would cause aliasing distortion at the desired sampling rate. Let's call this filter $h_a(x)$.
  3. Convert the continuous-domain signal, $f(x)$, to a new discrete-domain signal, $g[n]$, by sampling $f(x)$ at the desired rate: $g[n] = f(nT)$.

One key to understanding the imresize approach is to recognize that filtering with two filters in succession, in this case $h(x)$ and $h_a(x)$, can be replaced by one filter whose frequency response is the product of the original two filters. The second key to understanding the imresize algorithm is that the desired frequency response for the antialiasing filter, $h_a(x)$, depends how much we are changing the sampling rate. If we shrink the original signal more, then we have to remove more of the high frequencies with $h_a(x)$.

To state that more compactly (while waving my hands fairly vigorously), you can use just one continuous-domain filter to simultaneously accomplish interpolation and antialiasing.

Let me show you how this works for the cubic interpolation kernel that imresize uses by default. Here is the code for the cubic interpolation kernel:

function f = cubic(x) % See Keys, "Cubic Convolution Interpolation for Digital Image % Processing," IEEE Transactions on Acoustics, Speech, and Signal % Processing, Vol. ASSP-29, No. 6, December 1981, p. 1155.absx = abs(x); absx2 = absx.^2; absx3 = absx.^3;f = (1.5*absx3 - 2.5*absx2 + 1) .* (absx <= 1) + ... (-0.5*absx3 + 2.5*absx2 - 4*absx + 2) .* ... ((1 < absx) & (absx <= 2));

(This code is inside the file imresize.m.) And here's what the interpolation kernel looks like:

figure fplot(@cubic,[-2.5 2.5],'LineWidth',2.0)

The function imresize then modifies the interpolation by stretching it out. The stretch factor depends directly how much we are shrinking the original signal. Here's the imresize code that modifies the interpolation kernel:

if (scale < 1) && (antialiasing) % Use a modified kernel to simultaneously interpolate and % antialias. h = @(x) scale * kernel(scale * x); kernel_width = kernel_width / scale; else % No antialiasing; use unmodified kernel. h = kernel; end

(I don't always comment my code well, but I think I did OK here.)

Notice that we don't modify the kernel at all when we are growing a signal (scale > 1) instead of shrinking it (scale < 1).

Here are three versions of the cubic interpolation kernel: the original one, one modified for shrinking by a factor of 2, and one modified by shrinking by a factor of 4.

h1 = @cubic; h2 = @(x) 0.5 * h1(0.5*x); h4 = @(x) 0.25 * h1(0.25*x); fplot(h1,[-10 10],'LineWidth',2) hold on fplot(h2,[-10 10],'LineWidth',2) fplot(h4,[-10 10],'LineWidth',2) hold off legend('h_1(x)','h_2(x)','h_4(x)')

When we spread out the interpolation kernel in this way, the interpolation computation averages pixel values from a wider neighborhood to produce each output pixel. That is additional smoothing, which gives us the desired antialiasing effect.

Here is the imresize output for the zone plate image again.

imshow(Z4_imresize)

Only the rings near the center are visible. That's because those rings had lower spatial frequency in the original, and they can be successfully represented using only one-fourth the sampling rate. The higher-frequency rings further away from the center have been smoothed away into a solid gray.

You can experiment yourself with imresize by disabling antialiasing. Here's how to shrink an image with antialiasing turned off:

Z4_imresize_noaa = imresize(Z,0.25,'Antialiasing',false); imshow(Z4_imresize_noaa)

To give credit where credit is due, the algorithm used by imresize was inspired by the article "General Filtered Image Rescaling," by Dale Schumacher, in Graphics Gems III, Morgan Kaufmann, 1994.

Do you have other questions about imresize? Let me know by leaving a comment.

\n'); d.write(code_string); // Add copyright line at the bottom if specified. if (copyright.length > 0) { d.writeln(''); d.writeln('%%'); if (copyright.length > 0) { d.writeln('% _' + copyright + '_'); } } d.write('\n'); d.title = title + ' (MATLAB code)'; d.close(); } -->


Get the MATLAB code (requires JavaScript)

Published with MATLAB® R2016b

1|) instead of shrinking it (|scale < 1|). % % Here are three versions of the cubic interpolation kernel: the original one, % one modified for shrinking by a factor of 2, and one modified by % shrinking by a factor of 4. h1 = @cubic; h2 = @(x) 0.5 * h1(0.5*x); h4 = @(x) 0.25 * h1(0.25*x); fplot(h1,[-10 10],'LineWidth',2) hold on fplot(h2,[-10 10],'LineWidth',2) fplot(h4,[-10 10],'LineWidth',2) hold off legend('h_1(x)','h_2(x)','h_4(x)') %% % When we spread out the interpolation kernel in this way, the % interpolation computation averages pixel values from a wider neighborhood % to produce each output pixel. That is additional smoothing, which % gives us the desired antialiasing effect. % % Here is the |imresize| output for the zone plate image again. imshow(Z4_imresize) %% % Only the rings near the center are visible. That's because those rings % had lower spatial frequency in the original, and they can be successfully % represented using only one-fourth the sampling rate. The higher-frequency % rings further away from the center have been smoothed away into a solid % gray. % % You can experiment yourself with |imresize| by disabling % antialiasing. Here's how to shrink an image with antialiasing turned off: Z4_imresize_noaa = imresize(Z,0.25,'Antialiasing',false); imshow(Z4_imresize_noaa) %% % To give credit where credit is due, the algorithm used by |imresize| was % inspired by the article "General Filtered Image Rescaling," by Dale % Schumacher, in _Graphics Gems III_, Morgan Kaufmann, 1994. % % Do you have other questions about |imresize|? Let me know by leaving a % comment. ##### SOURCE END ##### b15b81f80bae4208bbaf292a3ba87035 -->

Categories: Blogs

Why the Trump era is the perfect time to go long on freedom and short on surveillance

Cory Doctorow - 2017, January 12 - 07:34



My new Locus column is “It’s Time to Short Surveillance and Go Long on Freedom,” which starts by observing that Barack Obama’s legacy includes a beautifully operationalized, professional and terrifying surveillance apparatus, which Donald Trump inherits as he assumes office and makes ready to make good on his promise to deport millions of Americans and place Muslims under continuous surveillance.


But Trump supporters shouldn’t get too happy about this: after all, the billions Trump will pour into expanding America’s surveillance apparatus will be inherited by his successor — who may well be a Democrat who uses it for their own political ends.

The expansion of surveillance in the Trump era will create more and more people with direct experience of the perils of mass surveillance — and thus a larger audience for tools, products and services to help them safeguard their privacy. Privacy and surveillance are classic public health problems: because the downsides are so distant from the activity, it’s hard for us to make good judgments about when and how we should trade our privacy away. This is the same pattern that makes smoking so hard to combat.

Just as with smoking, surveillance will eventually reach the point of “peak indifference” — when the number of people who want to do something only goes up and up. That moment has already passed, and the Trump years will only accelerate the opposition to surveillance.


How can you short the surveillance economy and go long on technological freedom? Personally, you can peruse the easy-to-follow ‘‘Surveillance Self Defense’’ documentation maintained (in 11 languages!) by the Electronic Frontier Foundation (https://ssd.eff.org), and get your friends to do the same (remember, privacy is a team sport – it doesn’t matter if you keep your messages secure if your correspondents leave them in plain sight).

But if you’re minded to think about new businesses and business mod­els, get thinking about how you might offer services to protect people from the backdoored, hyper-invasive Internet of Things. What about a Facebook login tool that scrapes all your feeds by clicking everything and downloading it all, then letting you choose what you see without letting Facebook know, depriving Facebook of information about the choices you make and the places you are when you make them? That’ll get you sued by Facebook under the Computer Fraud and Abuse Act, but who knows, maybe a peak-indifference judge will find in your favor. Facebook has a lot of users who like the utility of hanging out with their friends and will increasingly be terrified of the consequences of hemorrhaging their data directly into Mark Zuckerberg’s remorseless, gaping maw.

Think of how you could jailbreak Philips lightbulbs and HP printers and ‘‘smart’’ TVs and games consoles and cable boxes and load them with software that treats your personal data as if it was precious lifeblood, not the consequence-free exhalations of your digital metabolism. That’ll get you sued under Section 1201 of the Digital Millennium Copy­right Act, and again, we’ll have to see whether a peak-indifference judge will decide that’s what Congress meant when they passed the DMCA in 1998. But that’s what limited liability companies are for, right?

Most importantly, you short the surveillance economy by investing in the activist groups that are fighting to make it legally safe to command your devices to stop stabbing you in the back and start guarding your back. That’s groups like the Electronic Frontier Foundation (eff.org; dis­closure, I consult to, but don’t earn money from, the EFF), the American Civil Liberties Union (ACLU), and many, many others.

We’ve got a rough four years ahead of us, and it’s going to get a lot worse before it gets better. But the only thing that could make the privacy catastrophes of the coming years even worse is if we let them go to waste.

It’s Time to Short Surveillance and Go Long on Freedom [Cory Doctorow/Locus Magazine]

(Images: Warded Lock, Thegreenj, CC-BY-SA; Donald Trump, Michael Vadon, CC-BY-SA)

Categories: Blogs

Two award wins & a staged reading with Ed Asner!

Casey McKinnon - 2017, January 10 - 20:07

2017 is off to an incredible start!

I am happy to announce that I won a BroadwayWorld Award in the category of Best Featured Actress for my role as Jackie Kennedy in The Tragedy of JFK. I'm also proud to say that fellow cast mates Tony Abatemarco and Susan Denaker, who played J. Edgar Hoover and Lady Bird Johnson, also won awards for Best Lead Actor and Actress. My deepest thanks to everyone who voted.

I also received recognition from The Last Straw Awards, where each year Los Angeles theatre reviewer Joe Straw names a number of artists who inspire him with their unique and hair raising work. In addition to myself, Straw named fellow cast members Time Winters, Tony Abatemarco, Chad Brannon, Jacob Sidney, and Cris D'Annunzio for their distinguished work, as well as our magnificent writer/director Daniel Henning. Thanks, Joe!

Photo courtesy of Rudy Jahchan.

And, if that wasn't enough, I got to start my year acting in a staged reading of Persephone Unbound with entertainment legend Ed Asner. Initially I had been cast in a supporting role, but after our first rehearsal, Ed had some very flattering things to say about me and the next thing I knew the producers called and offered me the lead role of Persephone! The play is a coming of age story based on Greek mythology and following a young Persephone who rebels against her parents by running away with Hades, god of the underworld. Ed Asner played my father Zeus, and the entire cast was made up of highly accomplished and recognizable actors. I was pleased to work with Chad Brannon a second time, and to become acquainted with Irene Roseen and James Handy, who I greatly admire.

All in all, I think this is a great start to the new year, and I look forward to what else 2017 has in store.

Categories: Blogs