Skip to content
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
2fa63f8
first commit on stefanos branch
steve-anunknown Mar 25, 2023
a087796
plots now printed all at once
steve-anunknown Mar 25, 2023
7896bbc
Delete cv23_lab1_part12_material.zip
Spyros-P Mar 25, 2023
40bbdf2
implemented the quality criterion
steve-anunknown Mar 25, 2023
ffdc352
Merge remote-tracking branch 'origin/stefanos' into stefanos
steve-anunknown Mar 25, 2023
b8dcc94
implemented the quality criterion
steve-anunknown Mar 25, 2023
a5e2312
added some code for kyoto processing, but does not work, resulting im…
steve-anunknown Mar 25, 2023
b71f48a
finished the real image processing part and it works, however, the pa…
steve-anunknown Mar 26, 2023
0b3ec94
cleaned up the code a little bit
steve-anunknown Mar 26, 2023
ea87c39
cleaned up the code a little bit
steve-anunknown Mar 26, 2023
547c882
implemented the first part of corner detection
steve-anunknown Mar 26, 2023
5226a38
finished the corner detection, we have to play around with the parame…
steve-anunknown Mar 27, 2023
50685fb
finished the corner detection, we have to play around with the parame…
steve-anunknown Mar 27, 2023
8f00b67
added some comments
steve-anunknown Mar 27, 2023
e960664
added some comments
steve-anunknown Mar 27, 2023
f655c18
implemented the blob detection. also, took some repeated code and tur…
steve-anunknown Mar 28, 2023
f30858c
implemented the blob detection. also, took some repeated code and tur…
steve-anunknown Mar 28, 2023
cf89124
wrote a shit tone of code, that is, some functions that use boxes to …
steve-anunknown Mar 29, 2023
126f045
Reorganized the code. Added some comments,
steve-anunknown Mar 29, 2023
44fa7fb
added a small comment in the log metric function
steve-anunknown Mar 29, 2023
73cd5e6
Replaced an incomprehensible function with a more
steve-anunknown Mar 29, 2023
74ad7b5
Reorganized the code into files
steve-anunknown Apr 1, 2023
bd696e2
sped up the laplacian corner detection
steve-anunknown Apr 1, 2023
2e6787f
Uploaded the blob detection files.
steve-anunknown Apr 1, 2023
6a27b58
TRIED TO OPTIMIZE BUT STILL NOT GOOD ENOUGH
steve-anunknown Apr 1, 2023
9ead495
organized the code into files. most of it is working. need to fix the…
steve-anunknown Apr 2, 2023
a7cd2c3
Perhaps everything works as intended now
steve-anunknown Apr 3, 2023
d69ed50
removed some files
steve-anunknown Apr 3, 2023
bef474e
removed some pycache files
steve-anunknown Apr 3, 2023
5addf0d
updated gitignore and removed a temporary file
steve-anunknown Apr 3, 2023
1ff2345
updated gitignore
steve-anunknown Apr 3, 2023
aa7f867
removed proxeirocvlab1.txt
steve-anunknown Apr 3, 2023
2f816b1
modified the scripts so that they store the image plots and also uplo…
steve-anunknown Apr 3, 2023
7d01ec9
added some comments
steve-anunknown Apr 3, 2023
5b46bf8
added numba support to make it faster, also produced better image plo…
steve-anunknown Apr 3, 2023
2585851
updated README.md
steve-anunknown Apr 3, 2023
a482ec7
fixed the edge detection intro script
steve-anunknown Apr 3, 2023
dc06685
stuff
steve-anunknown Apr 3, 2023
db3eb8b
wrote a big part of the report, cropped some image plots and slightly…
steve-anunknown Apr 4, 2023
71943bc
the box filter speedup finally works
steve-anunknown Apr 5, 2023
add33bb
box implementation and simple implementation run at best at the same …
steve-anunknown Apr 6, 2023
23c247a
finished report
steve-anunknown Apr 6, 2023
96cbfb1
reorganized images
steve-anunknown Apr 6, 2023
1f022f2
reorganized folder structure
steve-anunknown Apr 6, 2023
8d96ab7
cleaned up report files
steve-anunknown Apr 6, 2023
c9230f8
fixed the zip file
steve-anunknown Apr 6, 2023
a3b02d0
updated gitignore
steve-anunknown Apr 19, 2023
dae3f40
updated gitignore
steve-anunknown Apr 19, 2023
ab47c33
updated gitignore
steve-anunknown Apr 19, 2023
3c86d90
extracted some features and organized file structure
steve-anunknown Apr 20, 2023
86e5369
updated gitignore
steve-anunknown Apr 20, 2023
42b1e51
removed unnecessary photos
steve-anunknown Apr 20, 2023
d375496
removed an unnecessary .py file
steve-anunknown Apr 20, 2023
46a32c9
added results of different classifiers
steve-anunknown Apr 20, 2023
383ba63
updated notebook
steve-anunknown Apr 20, 2023
b67adb7
fixed bug
Spyros-P Apr 20, 2023
7d0948a
fixed bug (true)
Spyros-P Apr 20, 2023
eb41a1c
tried to implement Bag of Visual Words.
steve-anunknown Apr 21, 2023
d19452e
implemented bag of visual words. It is slower than the precompiled ve…
steve-anunknown Apr 21, 2023
921b7d8
implemented Bag of Visual Words. Slower than the precompiled one.
steve-anunknown Apr 21, 2023
e0dcb5c
classification results with less clusters and iterations
steve-anunknown Apr 21, 2023
235846a
changed a printing method
steve-anunknown Apr 21, 2023
9a7244b
updated report folder
steve-anunknown Apr 21, 2023
af5a37f
updated report
steve-anunknown Apr 21, 2023
8953e04
removed some files that were added by accident
steve-anunknown Apr 21, 2023
e4457ed
changed how some results are printed
steve-anunknown Apr 21, 2023
b170eeb
changed formatting
steve-anunknown Apr 21, 2023
2e1f75a
formatted texts
steve-anunknown Apr 21, 2023
74bde60
updated report. the only thing left is the final conclusion. some mor…
steve-anunknown Apr 21, 2023
56cc031
renamed a folder
steve-anunknown Apr 21, 2023
4a0f7c8
removed old folder
steve-anunknown Apr 21, 2023
c744084
updated notebook
steve-anunknown Apr 21, 2023
422eea1
finished report
steve-anunknown Apr 22, 2023
f3e1b0a
slight alterations
steve-anunknown Apr 22, 2023
475c0eb
added some sorted results
steve-anunknown Apr 22, 2023
321cefc
added the final submission folder
steve-anunknown Apr 23, 2023
c93adf7
added some files. split the notebook into scripts.
steve-anunknown Apr 23, 2023
65bb20a
readme for lab2
steve-anunknown May 17, 2023
290dbd9
added results
steve-anunknown May 17, 2023
66b0f96
created scripts for first part of lab2
steve-anunknown May 17, 2023
5d66964
filled in functions and some basic "main" code.
steve-anunknown May 23, 2023
d7bfaf5
filled in the lucas kanade function. not tested.
steve-anunknown May 23, 2023
00cdaa4
updated the git ignore
steve-anunknown May 23, 2023
2d495ab
updates
steve-anunknown May 23, 2023
d953ee6
they seem to be working now.
steve-anunknown May 23, 2023
627e825
trying to implement lucas kanade
steve-anunknown May 24, 2023
1c882ee
this is a backup
steve-anunknown May 30, 2023
aca581d
this seems to be correct now
steve-anunknown May 30, 2023
94ed497
this needs fixing
steve-anunknown May 30, 2023
a4fb5b5
removed some messages
steve-anunknown May 30, 2023
c8913e2
trying to correctly setup main
steve-anunknown May 30, 2023
41d5e85
that's trash basically but keep it
steve-anunknown May 30, 2023
335feba
checked and working.
steve-anunknown May 31, 2023
e343d51
they seem to completely working now
steve-anunknown May 31, 2023
a202370
added multiscale implementation. not tested.
steve-anunknown May 31, 2023
5ea9057
made some structural changes
steve-anunknown May 31, 2023
2a665f9
not ready yet. probably close to being ready
steve-anunknown May 31, 2023
8f8c7f5
multiscale implementation completed
steve-anunknown May 31, 2023
260449b
reformatted the code
steve-anunknown May 31, 2023
c402a0f
started implementing
steve-anunknown Jun 1, 2023
1cc8785
uploaded gifs of part1 tracking
steve-anunknown Jun 3, 2023
3de93d5
added functions that produce gifs
steve-anunknown Jun 3, 2023
2c0ef46
implemented harris and gabor detector. not tested.
steve-anunknown Jun 3, 2023
a1f0525
they are not working as expected
steve-anunknown Jun 3, 2023
b913609
they should be working but aren't.
steve-anunknown Jun 5, 2023
d7c1115
uniscale gabor and harris working. gabor seems better
steve-anunknown Jun 6, 2023
25a2797
trying to implement multiscale versions
steve-anunknown Jun 6, 2023
77750fb
something like a backup
steve-anunknown Jun 6, 2023
552fcad
implemented multiscale detector. harris seems crap but gabor seems to…
steve-anunknown Jun 7, 2023
d9d525e
started implementing the classification script. must train classifier…
steve-anunknown Jun 7, 2023
f54df80
slightly changed the detectors' definition
steve-anunknown Jun 7, 2023
49f3636
finished classification script and descriptors. descriptors produce e…
steve-anunknown Jun 7, 2023
8459b6d
added todos
steve-anunknown Jun 7, 2023
dd0e2f0
minor changes
steve-anunknown Jun 7, 2023
f6dbde9
updated gitignore
steve-anunknown Jun 7, 2023
0db20d6
added part3 but no work has been done on it
steve-anunknown Jun 7, 2023
f25b70a
updated gitignore
steve-anunknown Jun 7, 2023
fed923a
added classification results
steve-anunknown Jun 8, 2023
9a740b0
fixed harris detector. problem was not there but in the interest_poin…
steve-anunknown Jun 8, 2023
ac3ff63
reformatted code
steve-anunknown Jun 9, 2023
27acf3d
moved results into appropriate folder
steve-anunknown Jun 9, 2023
d4292b2
slight changes
steve-anunknown Jun 10, 2023
e0a956b
fell back to the original form due to some problems that i could not …
steve-anunknown Jun 10, 2023
3701e79
reformatted the shit out of this bad boy.
steve-anunknown Jun 10, 2023
920c68b
fixed some oversights
steve-anunknown Jun 10, 2023
d2c17b8
added classification results
steve-anunknown Jun 11, 2023
494a3af
updated gitignore
steve-anunknown Jun 11, 2023
caf86c1
updated gitignore
steve-anunknown Jun 11, 2023
4884257
it works for uniscale
steve-anunknown Jun 11, 2023
8f0f0f5
removed classification.log
steve-anunknown Jun 11, 2023
4358ce2
i don't remember, but probably slight changes
steve-anunknown Jun 11, 2023
fc46183
removed old results
steve-anunknown Jun 11, 2023
1745137
added stiching main function
steve-anunknown Jun 12, 2023
a8106c7
added stitching utils
steve-anunknown Jun 12, 2023
2ef8987
works
steve-anunknown Jun 12, 2023
ab78036
utils work but not all
steve-anunknown Jun 12, 2023
e1fb5fb
added results
steve-anunknown Jun 12, 2023
e3a2ace
this is for trials
steve-anunknown Jun 12, 2023
89ba676
added some comments i think
steve-anunknown Jun 12, 2023
936a949
added report essentials
steve-anunknown Jun 14, 2023
1ecb811
removed old files
steve-anunknown Jun 14, 2023
25480b8
final folder for submission
steve-anunknown Jun 15, 2023
f701a3b
final part1
steve-anunknown Jun 15, 2023
1fa1611
final part2
steve-anunknown Jun 15, 2023
40893b4
final part3
steve-anunknown Jun 15, 2023
498c0e3
updated gitignore
steve-anunknown Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*.zip
__*__
trash
cv23_lab1_part3_material/Data/
/Data
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# ntua-cv-lab

This is a private repository for the version control of the lab projects of the Computer Vision course of ECE NTUA

In order for the code to be properly run, the scripts have to executed in an environment with opencv, numpy, scikit-learn, tqdm, and matplotlib. For jupyter support, jupyter and nb_conda_kernels should also be included. Following is a command to create a virtual environment in conda.

```
conda create -n cv_lab1_env python=3.7 opencv=3.4.2 numpy scikit-learn tqdm matplotlib jupyter nb_conda_kernels

conda activate cv_lab1_env
```

Numba (a just in time compiler for python) should also be installed in order for the box_detection scripts to be fast.

```
conda install numba
```
Binary file removed lab1/cv23_lab1_part12_material.zip
Binary file not shown.
101 changes: 0 additions & 101 deletions lab1/cvlab1.py

This file was deleted.

Binary file added lab1/image-plots/blob-detection-cells-bad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-cells-good.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-cells.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-ii-cells.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-ii-up.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-multiscale-up.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/blob-detection-up.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/cells-gray.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added lab1/image-plots/corner-detection-eigenvalues.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/corner-detection-multiscale.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/corner-detection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/edges-intro0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/edges-intro1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/edges-real.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab1/image-plots/grad-comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
67 changes: 67 additions & 0 deletions lab1/part12/blob_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import cv2
import numpy as np
import matplotlib.pyplot as plt
from blob_detection_utils import BlobDetection
from blob_detection_utils import HessianLaplacian
from cv23_lab1_part2_utils import interest_points_visualization

# TESTED AND WORKING

def blobtest():
up = cv2.imread("cv23_lab1_part12_material/up.png")
up = cv2.cvtColor(up, cv2.COLOR_BGR2RGB)
gray = cv2.imread("cv23_lab1_part12_material/up.png", cv2.IMREAD_GRAYSCALE)
gray = gray.astype(np.float64)/gray.max()

# play around with the parameters
sigma = 2.5
theta = 0.05
scale = 1.1
N = 8

blobs = BlobDetection(gray, sigma, theta)
interest_points_visualization(up, blobs, None)
plt.savefig(f"image-plots/blob-detection-up.jpg")

# play around with the parameters
blobs = HessianLaplacian(gray, sigma, theta, scale, N)
interest_points_visualization(up, blobs, None)
plt.savefig(f"image-plots/blob-detection-multiscale-up.jpg")

cells = cv2.imread("cv23_lab1_part12_material/cells.jpg")
cells = cv2.cvtColor(cells, cv2.COLOR_BGR2RGB)
gray = cv2.imread("cv23_lab1_part12_material/cells.jpg", cv2.IMREAD_GRAYSCALE)
gray = gray.astype(np.float64)/gray.max()

# play around with the parameters
sigma = 3
theta = 0.05
scale = 1.1
N = 8

blobs = BlobDetection(gray, sigma, theta)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-cells-bad.jpg")

# play around with the parameters
blobs = HessianLaplacian(gray, sigma, theta, scale, N)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-multiscale-cells-bad.jpg")

# play around with the parameters
sigma = 3
theta = 0.15
scale = 1.1
N = 8

blobs = BlobDetection(gray, sigma, theta)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-cells-good.jpg")

# play around with the parameters
blobs = HessianLaplacian(gray, sigma, theta, scale, N)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-multiscale-cells-good.jpg")

blobtest()
plt.show()
35 changes: 35 additions & 0 deletions lab1/part12/blob_detection_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import numpy as np
import time
from intro_utils import smooth_gradient
from intro_utils import InterestPointCoord
from intro_utils import LogMetric

def BlobDetection(image, sigma, theta):
gradxx, gradxy, gradyy = smooth_gradient(image, sigma, 2)
r = gradxx * gradyy - gradxy * gradxy # determinant of hessian
indices = InterestPointCoord(r, sigma, theta)
scale = sigma*np.ones((indices.shape[0], 1))
blobs = np.concatenate((indices, scale), axis=1)
return blobs

def HessianLaplacian(image, sigma, theta, scale, N):
scales = [scale**i for i in list(range(N))]
sigmas = [scale * sigma for scale in scales]

gradsxx = []
gradsyy = []
blobs_per_scale = []
for s in sigmas:
lxx, lxy, lyy = smooth_gradient(image, s, 2)
r = lxx * lyy - lxy * lxy # determinant of hessian
indices = InterestPointCoord(r, s, theta)
scale = s*np.ones((indices.shape[0], 1))
blobs = np.concatenate((indices, scale), axis=1)

gradsxx.append(lxx)
gradsyy.append(lyy)
blobs_per_scale.append(blobs)

grads = list(zip(scales, gradsxx, gradsyy))
logs = [(s**2)*np.abs(xx + yy) for (s, xx, yy) in grads]
return LogMetric(logs, blobs_per_scale, N)
68 changes: 68 additions & 0 deletions lab1/part12/box_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import cv2
import numpy as np
import matplotlib.pyplot as plt
from box_detection_utils import BoxFilters
from box_detection_utils import BoxLaplacian
from cv23_lab1_part2_utils import interest_points_visualization

# THIS WORKS NOW, HOWEVER IT IS NOT SPED UP.
# THE SPEED UP ACTUALLY DEPENDS ON HOW THE
# SIMPLE BLOB DETECTION FUNCTION WORKS.

# IF IT IS IMPLEMENTED USING THE BUILT IN
# FILTER2D AND GAUSSIAN FUNCTIONS, THEN
# IT IS ALREADY REALLY FAST AND ITS TIME
# COMPLEXITY DOES NOT DEPEND ON THE SIGMA
# PARAMETER. IF A MANUAL CONVOLUTION HAS
# BEEN USED, THEN A HUGE SPEEDUP (OR ACTUALLY SLOW DOWN)
# WILL BE NOTICEABLE.

def boxtest():
up = cv2.imread("cv23_lab1_part12_material/up.png")
up = cv2.cvtColor(up, cv2.COLOR_BGR2RGB)
gray = cv2.imread("cv23_lab1_part12_material/up.png", cv2.IMREAD_GRAYSCALE)
gray = gray.astype(np.float64)/gray.max()

# play around with the parameters
sigma = 2.5
theta = 0.05

blobs = BoxFilters(gray, sigma, theta)
interest_points_visualization(up, blobs, None)
plt.savefig(f"image-plots/blob-detection-ii-up.jpg")

# play around with the parameters
sigma = 2.5
theta = 0.05
scale = 1.1
N = 8

blobs = BoxLaplacian(gray, sigma, theta, scale, N)
interest_points_visualization(up, blobs, None)
plt.savefig(f"image-plots/blob-detection-multiscale-ii-up.jpg")

cells = cv2.imread("cv23_lab1_part12_material/cells.jpg")
cells = cv2.cvtColor(cells, cv2.COLOR_BGR2RGB)
gray = cv2.imread("cv23_lab1_part12_material/cells.jpg", cv2.IMREAD_GRAYSCALE)
gray = gray.astype(np.float64)/gray.max()

# play around with the parameters
sigma = 3
theta = 0.05

blobs = BoxFilters(gray, sigma, theta)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-ii-cells.jpg")

# play around with the parameters
sigma = 3
theta = 0.05
scale = 1.1
N = 8

blobs = BoxLaplacian(gray, sigma, theta, scale, N)
interest_points_visualization(cells, blobs, None)
plt.savefig(f"image-plots/blob-detection-multiscale-ii-cells.jpg")

boxtest()
plt.show()
98 changes: 98 additions & 0 deletions lab1/part12/box_detection_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import numpy as np
import time
from intro_utils import LogMetric
from intro_utils import InterestPointCoord


def IntegralImage(i):
# this definitely works
return np.cumsum(np.cumsum(i, axis=0), axis=1)

def BoxDerivative(image, sigma):
def roi(ii, x, y, padw):
# rectangle of interest
# the input image is padded, otherwise the shifts
# would have peculiar results

# therefore remeber to unpad in the end

# take the whole integral image and move it around
# the area outside of the rectangle will cancel itself out
# leaving only the values inside the rectangle of interest
shiftx = int((x + 1)/2 - 1)
shifty = int((y + 1)/2 - 1)

# this isolates the upper and lower line
upline = np.roll(ii, shifty + 1, axis=0)
loline = np.roll(ii, -shifty, axis=0)

# this isolates the upper corners
uprigh = np.roll(upline, -shiftx, axis=1)
upleft = np.roll(upline, shiftx+1, axis=1)

# this isolates the lower corners
downri = np.roll(loline, -shiftx, axis=1)
downle = np.roll(loline, shiftx+1, axis=1)

result = upleft - uprigh + downri - downle
# unpad in the end
result = result[padw:-padw, padw:-padw]
return result

n = int(2*np.ceil(3*sigma) + 1)
height = int(4*np.floor(n/6) + 1)
width = int(2*np.floor(n/6) + 1)
padding = 2 * width

padded = np.pad(image, padding, 'reflect')
ii = IntegralImage(padded)

# sum the middle rectangle x(-3) and then add the whole rectangle
# (0 -3 0) + (1 1 1) = (1 -2 1)
lxx = -3*(roi(ii, width, height, padding)) + roi(ii, 3*width, height, padding)
lyy = -3*(roi(ii, height, width, padding)) + roi(ii, height, 3*width, padding)

# the xy derivative requires a little special handling
smallbox = roi(ii, width, width, padding)
padded = np.pad(smallbox, padding, 'reflect')
shiftv = int((width-1)/2 + 1)

ul = np.roll(padded, [shiftv, shiftv], axis=(0, 1))
ur = np.roll(padded, [-shiftv, shiftv], axis=(0, 1))
dl = np.roll(padded, [shiftv, -shiftv], axis=(0, 1))
dr = np.roll(padded, [-shiftv, -shiftv], axis=(0, 1))

lxy = ul + dr - ur - dl
lxy = lxy[padding:-padding, padding:-padding]

return (lxx, lxy, lyy)

def BoxFilters(image, sigma, theta):
lxx, lxy, lyy = BoxDerivative(image, sigma)
r = lxx*lyy - (0.9*lxy)**2
indices = InterestPointCoord(r, sigma, theta)
scale = sigma*np.ones((indices.shape[0], 1))
blobs = np.concatenate((indices, scale), axis=1)
return blobs

def BoxLaplacian(image, sigma, theta, scale, N):
scales = [scale**i for i in list(range(N))]
sigmas = [scale * sigma for scale in scales]

gradsxx = []
gradsyy = []
blobs_per_scale = []
for s in sigmas:
lxx, lxy, lyy = BoxDerivative(image, s)
r = lxx*lyy - (0.9*lxy)**2
indices = InterestPointCoord(r, s, theta)
scale = s*np.ones((indices.shape[0], 1))
blobs = np.concatenate((indices, scale), axis=1)

gradsxx.append(lxx)
gradsyy.append(lyy)
blobs_per_scale.append(blobs)

grads = list(zip(scales, gradsxx, gradsyy))
logs = [(s**2)*np.abs(xx + yy) for (s, xx, yy) in grads]
return LogMetric(logs, blobs_per_scale, N)
Loading