Skip to content
Snippets Groups Projects

modified to inline for figure to be visible

Merged bepi requested to merge bepi into master
1 file
+ 11
9
Compare changes
  • Side-by-side
  • Inline
  • 2d59ade8
    test · 2d59ade8
    bepi authored
+ 11
9
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
# Load relevant libraries
# Load relevant libraries
# scikit-image for image processing
# scikit-image for image processing
# Plot functions
# Plot functions
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
 
plt.gray();
%matplotlib inline
%matplotlib inline
%matplotlib notebook
%matplotlib notebook
 
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
# Matplotlib is used for displaying the image. The colormap is given by cmap = "gray". You can try differnet colormaps
# Matplotlib is used for displaying the image. The colormap is given by cmap = "gray". You can try differnet colormaps
# e.g. jet or summer
# e.g. jet or summer
plt.figure(figsize=(10,10))
plt.figure(figsize=(10,10))
plt.imshow(im_org, cmap="gray")
plt.imshow(im_org);
plt.show();
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
%% Output
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
plt.title('Threshold segmented image - boolean')
plt.title('Threshold segmented image - boolean')
plt.subplot(1,2,2)
plt.subplot(1,2,2)
plt.imshow(im_thres_float, cmap = "gray")
plt.imshow(im_thres_float);
plt.title('Threshold segmented image - float')
plt.title('Threshold segmented image - float')
plt.show();
%% Output
%% Output
 
Text(0.5, 1.0, 'Threshold segmented image - float')
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
%% Cell type:code id: tags:
%% Cell type:code id: tags:
print(im_thres[0,0])
print(im_thres[0,0])
# Let us try to go outside the image range. This will result in an index out of bounds error
# Let us try to go outside the image range. This will result in an index out of bounds error
print(im_thres[0,c])
print(im_thres[0,c])
%% Output
%% Output
---------------------------------------------------------------------------
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
IndexError Traceback (most recent call last)
<ipython-input-7-2b5ebf5825ae> in <module>
<ipython-input-21-fc2a6c938e6e> in <module>
7
7
8 # Let us try to go outside the image range. This will result in an index out of bounds error
8 # Let us try to go outside the image range. This will result in an index out of bounds error
----> 9 print(im_thres[0,c])
----> 9 print(im_thres[0,c])
10
11
IndexError: index 512 is out of bounds for axis 1 with size 512
IndexError: index 512 is out of bounds for axis 1 with size 512
%% Cell type:code id: tags:
%% Cell type:code id: tags:
Loading