Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SEU-CT-Recon/crip
Browse files Browse the repository at this point in the history
  • Loading branch information
z0gSh1u committed Jan 25, 2024
2 parents ef496df + f7384f7 commit 3d36345
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 42 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ An all-in-one tool for Cone-Beam CT Data IO, Pre/Post-process, Physics, Dual Ene

- Via [PyPI](https://pypi.org/project/crip/)

[![Upload Python Package](https://github.com/SEU-CT-Recon/crip/actions/workflows/python-publish.yml/badge.svg)](https://github.com/SEU-CT-Recon/crip/actions/workflows/python-publish.yml)

```sh
pip install crip
```
Expand Down
84 changes: 42 additions & 42 deletions crip/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ def makeImageGrid(subimages: List[TwoD],
'vmin0vmax1=False is not recommended because it might cause incorrect windowing. Make sure you know what you are doing.'
)

cripAssert(len(subimages) == ncols * nrows)
cripAssert(crops is None or len(crops) == nrows)

ncols = len(colTitles)
nrows = len(rowTitles)

cripAssert(len(subimages) == ncols * nrows, 'Number of subimages should be equal to ncols * nrows.')
cripAssert(crops is None or len(crops) == nrows, 'Number of crops should be equal to nrows.')

if isinstance(cropLocs, str):
cropLocs = [cropLocs] * nrows

Expand Down Expand Up @@ -164,47 +164,47 @@ def makeImageGrid(subimages: List[TwoD],
ax.get_xaxis().set_ticks([])
list(map(lambda x: x.set_visible(False), ax.spines.values()))

if i % ncols == 0:
if len(rects) != 0 and i % ncols == 0:
ax.add_patch(rects[i // ncols])

patch = zoomIn(im, *crops[i // ncols])
patch = resize(patch, (cropSize, cropSize))
cropLocs = cropLocs[i // ncols]

if cropLocs == 'bottom right':
im[-patch.shape[0]:, -patch.shape[1]:] = patch
patchRect = matplotlib.patches.Rectangle((im.shape[1] - patch.shape[1], im.shape[0] - patch.shape[0]),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'top left':
im[:patch.shape[0], :patch.shape[1]] = patch
patchRect = matplotlib.patches.Rectangle((0, 0),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'bottom left':
im[-patch.shape[0]:, :patch.shape[1]] = patch
patchRect = matplotlib.patches.Rectangle((0, im.shape[0] - patch.shape[0]),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'top right':
im[:patch.shape[0], -patch.shape[1]:] = patch
patchRect = matplotlib.patches.Rectangle((im.shape[1] - patch.shape[1], 0),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')

ax.add_patch(patchRect)
patch = zoomIn(im, *crops[i // ncols])
patch = resize(patch, (cropSize, cropSize))
cropLocs = cropLocs[i // ncols]

if cropLocs == 'bottom right':
im[-patch.shape[0]:, -patch.shape[1]:] = patch
patchRect = matplotlib.patches.Rectangle((im.shape[1] - patch.shape[1], im.shape[0] - patch.shape[0]),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'top left':
im[:patch.shape[0], :patch.shape[1]] = patch
patchRect = matplotlib.patches.Rectangle((0, 0),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'bottom left':
im[-patch.shape[0]:, :patch.shape[1]] = patch
patchRect = matplotlib.patches.Rectangle((0, im.shape[0] - patch.shape[0]),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')
elif cropLocs == 'top right':
im[:patch.shape[0], -patch.shape[1]:] = patch
patchRect = matplotlib.patches.Rectangle((im.shape[1] - patch.shape[1], 0),
patch.shape[1],
patch.shape[0],
linewidth=1,
edgecolor=cropEdgeColor,
facecolor='none')

ax.add_patch(patchRect)

if i < len(colTitles):
ax.set_title(colTitles[i], loc='center', fontdict=fontdict)
Expand Down

0 comments on commit 3d36345

Please sign in to comment.