I'm interrupting a series of blogs on the topic of complexity to provide a pointer to my recently constructed web page on batch image conversions.
When you write your own image software, you can automate activities that would otherwise require repeated operations, on multiple image files, with off-the-shelf image processing software. For example, you might want to delete, add, or modify annotations for a group of images, or you might want to resize an image collection to conform to specified dimensions. When you have more than a few images, you will not want to repeat the process by hand, for each image. When you have thousands of images, stored in a variety of image formats, it will be impossible to implement global conversions, if you do not know how to batch your operations.
The Batch conversions: Perl, Python, Ruby page provides three equivalent scripts, in Perl, Python and Ruby, that converts a batch of images from color to greyscale. The scripts are preceded by a step-by-step explanation of the code.
- © 2010 Jules Berman
tags: perl programming, python programming, ruby programming, image magick, imagemagick, grayscale, greyscale, big data, metadata, data preparation, data analytics, data repurposing, datamining, data mining, conversion, image format, image processing, perl, python, Ruby
Jules J. Berman Ph.D., M.D.
My book, Principles of Big Data: Preparing, Sharing, and Analyzing Complex Information was published in 2013 by Morgan Kaufmann.
I urge you to explore my book. Google books has prepared a generous preview of the book contents.
Devoted to the topic of data specification (including data organization, data description, data retrieval and data sharing) in the life sciences and in medicine.
Showing posts with label image format. Show all posts
Showing posts with label image format. Show all posts
Saturday, January 23, 2010
Friday, October 19, 2007
Adding a comment to a PNG or JPG header with Ruby and RMagick
Whenever you create and distribute an image, you should consider putting information in the header, such as the image title and your name and usage restrictions (if any). If you're putting the image into the public domain, you should specify that the image is a public domain image.
These issues are discussed in depth in my web page, Implementing an RDF Schema for Pathology Images.
The header of an image is a text block that is not visible when the image is viewed, but which can easily be stripped from the image.
Here is are two short Ruby scripts. The first script enters a comment into an image header. The second script extracts and displays the comment.
This scripts require RMagick, and instructions for acquiring RMagick are available.
The first script, pdfadd.rb, adds a comment to an image and copies the png image to
a jpg image.
The second script, pdf2.rb, extracts and prints the comment from the jpeg image.
The output of the second script is:
The image, neo1.png, is:

In June, 2014, my book, entitled Rare Diseases and Orphan Drugs: Keys to Understanding and Treating the Common Diseases was published by Elsevier. The book builds the argument that our best chance of curing the common diseases will come from studying and curing the rare diseases.
I urge you to read more about my book. There's a generous preview of the book at the Google Books site. If you like the book, please request your librarian to purchase a copy of this book for your library or reading room.
- Jules J. Berman, Ph.D., M.D. tags: common disease, orphan disease, orphan drugs, rare disease, disease genetics
These issues are discussed in depth in my web page, Implementing an RDF Schema for Pathology Images.
The header of an image is a text block that is not visible when the image is viewed, but which can easily be stripped from the image.
Here is are two short Ruby scripts. The first script enters a comment into an image header. The second script extracts and displays the comment.
script pdfadd.rb
#!/usr/local/bin/ruby
require 'RMagick'
include Magick
walnut = ImageList.new("neo1.png")
walnut.cur_image[:Comment] = "Developmental Lineage
Classification
of Neoplasms
Copyright (C) 2007
by Jules J. Berman
and distributed under
the GNU Free
Documentation License"
walnut_copy = ImageList.new
walnut_copy = walnut.cur_image.copy
walnut_copy.write("out.jpg")
exit
script pdf2.rb
#!/usr/local/bin/ruby
require 'RMagick'
include Magick
walnut = ImageList.new("out.jpg")
walnut.properties{|name, value|
print "#{name} #{value}\n"}
exit
This scripts require RMagick, and instructions for acquiring RMagick are available.
The first script, pdfadd.rb, adds a comment to an image and copies the png image to
a jpg image.
The second script, pdf2.rb, extracts and prints the comment from the jpeg image.
The output of the second script is:
C:\ftp>pdf2.rb
Comment Developmental Lineage
Classification
of Neoplasms
Copyright (C) 2007
by Jules J. Berman
and distributed under
the GNU Free
Documentation License
JPEG-Colorspace 1
JPEG-Sampling-factors 1x1
The image, neo1.png, is:

In June, 2014, my book, entitled Rare Diseases and Orphan Drugs: Keys to Understanding and Treating the Common Diseases was published by Elsevier. The book builds the argument that our best chance of curing the common diseases will come from studying and curing the rare diseases.
I urge you to read more about my book. There's a generous preview of the book at the Google Books site. If you like the book, please request your librarian to purchase a copy of this book for your library or reading room.
- Jules J. Berman, Ph.D., M.D. tags: common disease, orphan disease, orphan drugs, rare disease, disease genetics
Sunday, March 18, 2007
Searching patents related to DICOM
In yesterday's blog, I described how standards developers and standards users can search the USPTO (US Patent and trademark organization) for patents that might encumber a data standard.
As an example, let's look at some specific patents (issued or pending) related to DICOM (Digital Imaging and Communications in Medicine).
A search for pending patents (patent applications) on the term ttl/DICOM pulls just those patent applications that have DICOM in their title. A second search (through the issued patent search engine available from the same site) would pull issued patents.
Here is the output for pending patents submitted since 2001 and containing DICOM in the title.
If the word DICOM is in the title, it's a good bet that the patent will involve a method that uses the DICOM standard. The claims of such methods may possibly cover a user's intended uses of the standard. Had we simply done a search on the word "DICOM" without limiting the location of the search term to the title of the patent application, we would have retrieved 1144 patents from the USPTO patent application database. And these would just be those patents that are currently under review!
Notice that several of these methods seem to involve common tasks for informaticians who wish to tease out annotated data from a DICOM image and port the data and metadata into XML.
In the next blog, we'll look at one of the DICOM patents to determine the claims of the patent and the assignee of the patent.
-Jules Berman
Science is not a collection of facts. Science is what facts teach us; what we can learn about our universe, and ourselves, by deductive thinking. From observations of the night sky, made without the aid of telescopes, we can deduce that the universe is expanding, that the universe is not infinitely old, and why black holes exist. Without resorting to experimentation or mathematical analysis, we can deduce that gravity is a curvature in space-time, that the particles that compose light have no mass, that there is a theoretical limit to the number of different elements in the universe, and that the earth is billions of years old. Likewise, simple observations on animals tell us much about the migration of continents, the evolutionary relationships among classes of animals, why the nuclei of cells contain our genetic material, why certain animals are long-lived, why the gestation period of humans is 9 months, and why some diseases are rare and other diseases are common. In “Armchair Science”, the reader is confronted with 129 scientific mysteries, in cosmology, particle physics, chemistry, biology, and medicine. Beginning with simple observations, step-by-step analyses guide the reader toward solutions that are sometimes startling, and always entertaining. “Armchair Science” is written for general readers who are curious about science, and who want to sharpen their deductive skills.
As an example, let's look at some specific patents (issued or pending) related to DICOM (Digital Imaging and Communications in Medicine).
A search for pending patents (patent applications) on the term ttl/DICOM pulls just those patent applications that have DICOM in their title. A second search (through the issued patent search engine available from the same site) would pull issued patents.
Here is the output for pending patents submitted since 2001 and containing DICOM in the title.
If the word DICOM is in the title, it's a good bet that the patent will involve a method that uses the DICOM standard. The claims of such methods may possibly cover a user's intended uses of the standard. Had we simply done a search on the word "DICOM" without limiting the location of the search term to the title of the patent application, we would have retrieved 1144 patents from the USPTO patent application database. And these would just be those patents that are currently under review!
Notice that several of these methods seem to involve common tasks for informaticians who wish to tease out annotated data from a DICOM image and port the data and metadata into XML.
In the next blog, we'll look at one of the DICOM patents to determine the claims of the patent and the assignee of the patent.
-Jules Berman
Science is not a collection of facts. Science is what facts teach us; what we can learn about our universe, and ourselves, by deductive thinking. From observations of the night sky, made without the aid of telescopes, we can deduce that the universe is expanding, that the universe is not infinitely old, and why black holes exist. Without resorting to experimentation or mathematical analysis, we can deduce that gravity is a curvature in space-time, that the particles that compose light have no mass, that there is a theoretical limit to the number of different elements in the universe, and that the earth is billions of years old. Likewise, simple observations on animals tell us much about the migration of continents, the evolutionary relationships among classes of animals, why the nuclei of cells contain our genetic material, why certain animals are long-lived, why the gestation period of humans is 9 months, and why some diseases are rare and other diseases are common. In “Armchair Science”, the reader is confronted with 129 scientific mysteries, in cosmology, particle physics, chemistry, biology, and medicine. Beginning with simple observations, step-by-step analyses guide the reader toward solutions that are sometimes startling, and always entertaining. “Armchair Science” is written for general readers who are curious about science, and who want to sharpen their deductive skills.
Subscribe to:
Posts (Atom)

