Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosinglenna #549

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Binary file added docs/source/examples/boats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/examples/imageData.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


def load_image():
image = img.open('lenna.png')
image = img.open('boats.png')
pix = np.array(image)
channels = list(image.mode)
return pix, channels
Expand Down
28 changes: 7 additions & 21 deletions docs/source/examples/imageWithMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@

Author: Jan Grewe <[email protected]>

See https://github.com/G-node/nix/wiki for more information.

We use the "Lenna" image in this tutorial.

"Lenna" by Original full portrait: "Playmate of the Month". Playboy
Magazine. November 1972, photographed by Dwight Hooker.This 512x512
electronic/mechanical scan of a section of the full portrait:
Alexander Sawchuk and two others[1] - The USC-SIPI image
database. Via Wikipedia -
http://en.wikipedia.org/wiki/File:Lenna.png#mediaviewer/File:Lenna.png

"""
import numpy as np
import nixio as nix
Expand Down Expand Up @@ -58,7 +47,7 @@ def print_metadata_table(section, ax):


def load_image():
image = img.open('lenna.png')
image = img.open('boats.png')
pix = np.array(image)
channels = list(image.mode)
return pix, channels
Expand All @@ -80,20 +69,17 @@ def plot_data(data_array):
if docutils.is_running_under_pytest():
plt.close()
else:
fig.savefig('image_with_metadata.png')
fig.savefig('../images/image_with_metadata.png')
fig.show()


def add_image_information(nix_file):
section = nix_file.create_section('Image metadata', 'image_source')
section['Original name'] = 'Lenna'
section['Journal'] = 'Playboy Magazine'
section['Year'] = 1972
section['Month'] = 'November'
section['Author'] = 'Dwight Hooker'
section['Source'] = 'http://en.wikipedia.org/wiki/File:Lenna.png#mediaviewer/File:Lenna.png'
section['Comment'] = '512x512 electronic/mechanical scan of a section of the full portrait: Alexander Sawchuk and two others[1] - The USC-SIPI image database.'
section['Model'] = 'Lena Soederberg'
section['Original name'] = 'Boats'
section['Location'] = 'Port Louis'
section['Year'] = 2014
section['Month'] = 'August'
section['Author'] = 'Self'
return section


Expand Down
Binary file removed docs/source/examples/lenna.png
Binary file not shown.
31 changes: 11 additions & 20 deletions docs/source/examples/multipleROIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@

See https://github.com/G-node/nix/wiki for more information.

We use the "Lenna" image in this tutorial.

"Lenna" by Original full portrait: "Playmate of the Month". Playboy
Magazine. November 1972, photographed by Dwight Hooker.This 512x512
electronic/mechanical scan of a section of the full portrait:
Alexander Sawchuk and two others[1] - The USC-SIPI image
database. Via Wikipedia -
http://en.wikipedia.org/wiki/File:Lenna.png#mediaviewer/File:Lenna.png

"""

import nixio
Expand All @@ -33,7 +24,7 @@


def load_image():
image = img.open('lenna.png')
image = img.open('boats.png')
pix = np.array(image)
channels = list(image.mode)
return pix, channels
Expand Down Expand Up @@ -62,7 +53,7 @@ def plot_data(tag):
if docutils.is_running_under_pytest():
plt.close()
else:
# plt.savefig("../images/multiple_rois.png")
plt.savefig("../images/multiple_rois.png")
plt.show()


Expand All @@ -71,7 +62,7 @@ def plot_roi_data(tag):

fig = plt.figure(figsize=(5.5, 5.5))
for p in range(position_count):
roi_data = tag.tagged_data(p, "lenna")[:]
roi_data = tag.tagged_data(p, "boats")[:]
roi_data = np.array(roi_data, dtype='uint8')
ax = fig.add_subplot(position_count, 1, p + 1)
image = img.fromarray(roi_data)
Expand All @@ -80,7 +71,7 @@ def plot_roi_data(tag):
if docutils.is_running_under_pytest():
plt.close()
else:
# fig.savefig('../images/retrieved_rois.png')
fig.savefig('../images/retrieved_rois.png')
plt.show()


Expand All @@ -96,7 +87,7 @@ def main():

# create a 'DataArray' to take the sinewave, add some information about
# the signal
data = block.create_data_array("lenna", "nix.image.rgb", data=img_data)
data = block.create_data_array("boats", "nix.image.rgb", data=img_data)
# add descriptors for width, height and channels
data.append_sampled_dimension(1, label="height")
data.append_sampled_dimension(1, label="width")
Expand All @@ -105,14 +96,14 @@ def main():
num_regions = 3
num_dimensions = len(data.dimensions)
roi_starts = np.zeros((num_regions, num_dimensions), dtype=int)
roi_starts[0, :] = [250, 245, 0]
roi_starts[1, :] = [250, 315, 0]
roi_starts[2, :] = [340, 260, 0]
roi_starts[0, :] = [170, 50, 0]
roi_starts[1, :] = [250, 310, 0]
roi_starts[2, :] = [120, 425, 0]

roi_extents = np.zeros((num_regions, num_dimensions), dtype=int)
roi_extents[0, :] = [30, 45, 3]
roi_extents[1, :] = [30, 40, 3]
roi_extents[2, :] = [25, 65, 3]
roi_extents[0, :] = [240, 175, 3]
roi_extents[1, :] = [60, 135, 3]
roi_extents[2, :] = [170, 125, 3]

# create the positions DataArray
positions = block.create_data_array("ROI positions", "nix.positions", data=roi_starts)
Expand Down
21 changes: 6 additions & 15 deletions docs/source/examples/singleROI.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@

Author: Jan Grewe <[email protected]>

We use the "Lenna" image in this tutorial.

"Lenna" by Original full portrait: "Playmate of the Month". Playboy
Magazine. November 1972, photographed by Dwight Hooker.This 512x512
electronic/mechanical scan of a section of the full portrait:
Alexander Sawchuk and two others[1] - The USC-SIPI image
database. Via Wikipedia -
http://en.wikipedia.org/wiki/File:Lenna.png#mediaviewer/File:Lenna.png

"""

import nixio as nix
Expand All @@ -30,7 +21,7 @@


def load_image():
image = img.open('lenna.png')
image = img.open('boats.png')
pix = np.array(image)
channels = list(image.mode)
return pix, channels
Expand All @@ -54,7 +45,7 @@ def plot_data(tag):
draw_rect(img_data, pos, ext)
new_img = img.fromarray(img_data)
if not docutils.is_running_under_pytest():
# new_img.save("../images/single_roi.png")
new_img.save("../images/single_roi.png")
new_img.show()


Expand All @@ -69,16 +60,16 @@ def main():
block = f.create_block("block name", "nix.session")

# create a 'DataArray' to take the sinewave, add some information about the signal
data = block.create_data_array("lenna", "nix.image.rgb", data=img_data)
data = block.create_data_array("boats", "nix.image.rgb", data=img_data)
# add descriptors for width, height and channels
data.append_sampled_dimension(1, label="height")
data.append_sampled_dimension(1, label="width")
data.append_set_dimension(labels=channels)

# create a Tag, position and extent must be 3-D since the data is 3-D
position = [250, 250, 0]
extent = [30, 100, 3]
tag = block.create_tag('Region of interest', 'nix.roi', position)
position = [170, 50, 0]
extent = [240, 175, 3]
tag = block.create_tag('Sailing boat', 'nix.roi', position)
tag.extent = extent
tag.references.append(data)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/image_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ attribution in the code.

.. literalinclude:: examples/imageData.py
:lines: 59-64
:caption: Image data is just 3-D data that can be easily stored in a *DataArray*. We need to add three dimension descriptors, though (to run the example you need the :download:`example code <examples/imageData.py>` , the :download:`image <examples/lenna.png>` *imagemagick* or *xv* packages).
:caption: Image data is just 3-D data that can be easily stored in a *DataArray*. We need to add three dimension descriptors, though (to run the example you need the :download:`example code <examples/imageData.py>` , the :download:`image <examples/boats.png>` *imagemagick* or *xv* packages).

.. image:: examples/lenna.png
:alt: lenna
Expand Down
Binary file added docs/source/images/image_with_metadata.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/multiple_rois.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/retrieved_rois.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/images/single_roi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading