Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2fe792d

Browse files
committedJul 29, 2013
Update documentation (contrast GUI, test images, manipulation tools)
1 parent fff1d66 commit 2fe792d

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/images

‎README.md

+60-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ You'll need the `ImageView` package:
1010
Pkg.add("ImageView")
1111
```
1212

13-
## Demonstration
13+
## Preparation
1414

1515
First let's try it with a photograph. Load one this way:
1616
```
17-
using Images
18-
using ImageView
17+
using ImageView, Images
1918
img = imread("my_photo.jpg")
2019
```
21-
Any typical image format should be fine, it doesn't have to be a jpg.
22-
Now display the image this way:
20+
Any typical image format should be fine, it doesn't have to be a jpg. You can also use a GUI file-picker if you omit the filename:
21+
```
22+
img = imread()
23+
```
24+
Finally, ImageView comes with the ability to retrieve some standard test images:
25+
```
26+
using TestImages
27+
img = testimage("mandrill")
28+
```
29+
Currently, `mandrill`, `lighthouse`, `moonsurface`, and `mountainstream` are defined. It's easy to add more.
30+
31+
## Demonstration of the GUI
32+
33+
Now display the image:
2334
```
2435
display(img, pixelspacing = [1,1])
2536
```
@@ -109,3 +120,47 @@ Type 151 into the `y:` entry box (note its name has changed) and hit enter, or m
109120

110121
This GUI is also useful for "plain movies" (2d images with time), in which case the `z` controls will be omitted and it will behave largely as a typical movie-player.
111122
Likewise, the `t` controls will be omitted for 3d images lacking a temporal component, making this a nice viewer for MRI scans.
123+
124+
125+
Finally, for grayscale images, right-clicking on the image yields a brightness/contrast GUI:
126+
127+
![Contrast GUI snapshot](readme_images/contrast.jpg)
128+
129+
130+
## Programmatic usage
131+
132+
`display` returns two outputs:
133+
```
134+
imgc, imgslice = display(img)
135+
```
136+
`imgc` is an `ImageCanvas`, and holds information and settings about the display. `imgslice` is useful if you're supplying multidimensional images; from it, you can infer the currently-selected frame in the GUI.
137+
138+
Using these outputs, you can display a new image in place of the old one:
139+
```
140+
display(imgc, newimg)
141+
```
142+
This preserves settings (like `pixelspacing`); should you want to forget everything and start fresh, do it this way:
143+
```
144+
display(canvas(imgc), newimg)
145+
```
146+
`canvas(imgc)` just returns a [Tk Canvas](https://github.com/JuliaLang/Tk.jl/tree/master/examples), so this shows you can view images inside any pre-defined `Canvas`.
147+
148+
Likewise, you can close the display,
149+
```
150+
destroy(toplevel(imgc))
151+
```
152+
and resize it:
153+
```
154+
set_size(toplevel(imgc), w, h)
155+
```
156+
157+
Another nice tool is `canvasgrid`:
158+
```
159+
c = canvasgrid(2,2)
160+
ops = [:pixelspacing => [1,1]]
161+
display(c[1,1], testimage("lighthouse.png"); ops...)
162+
display(c[1,2], testimage("mountainstream"); ops...)
163+
display(c[2,1], testimage("moonsurface"); ops...)
164+
display(c[2,2], testimage("mandrill"); ops...)
165+
```
166+
![canvasgrid snapshot](readme_images/canvasgrid.jpg)

‎readme_images/canvasgrid.jpg

145 KB
Loading

‎readme_images/contrast.jpg

22.2 KB
Loading

‎test/testimages.jl

+7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ imagedict = [
1010
"mandrill.tiff" => "http://sipi.usc.edu/database/download.php?vol=misc&img=4.2.03"
1111
]
1212

13+
imagedict_noext = similar(imagedict)
14+
for (k,v) in imagedict
15+
base, ext = splitext(k)
16+
imagedict_noext[base] = k
17+
end
18+
1319
function testimage(filename, ops...)
1420
imagedir = joinpath(Pkg.dir(), "ImageView", "test", "images")
1521
if !isdir(imagedir)
1622
mkdir(imagedir)
1723
end
24+
filename = get(imagedict_noext, filename, filename)
1825
imagefile = joinpath(imagedir, filename)
1926
if !isfile(imagefile)
2027
download(imagedict[filename], imagefile)

0 commit comments

Comments
 (0)
Please sign in to comment.