Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DIP2-cheatsheet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanuel Aslan
DIP2-cheatsheet
Commits
52eb3bc0
Commit
52eb3bc0
authored
2 years ago
by
Amanuel Aslan
Browse files
Options
Downloads
Patches
Plain Diff
Update DIP2-cheatsheet.md
parent
226e7be9
Branches
aaslan-main-patch-37010
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DIP2-cheatsheet.md
+15
-0
15 additions, 0 deletions
DIP2-cheatsheet.md
with
15 additions
and
0 deletions
DIP2-cheatsheet.md
+
15
−
0
View file @
52eb3bc0
...
...
@@ -36,6 +36,7 @@ np.linspace(0,2,num=9, dtype) # evenly spaced values. Specify the number of valu
np
.
eye
(
2
,
dtype
)
# 2x2 identity matrix
np
.
random
.
random
((
2
,
2
))
# 2x2 array with random [0..1) values
np
.
random
.
randint
(
low
,
high
,
(
2
,
2
))
# 2x2 array with random integers from [low, high[ (w/o high!)
img_th
=
(
img
>
threshold
)
*
pixel
# (img > threshold) returns array with ones where true
```
### Array operations
...
...
@@ -51,6 +52,8 @@ np.maximum(array1, array2) # Returns new array with shape of array1 and array2 w
Calculate smallest
*odd*
interger not smaller than value (usefull for kernel size for gaussian filter)
```
python
int
(
np
.
ceil
(
value
)
//
2
*
2
+
1
)
# Alternative
n
=
value
if
value
%
2
==
1
else
value
+
1
```
Change type of the values of a numpy array. Possible types:
*np.float32*
,
*np.float64*
,
*np.int32*
,
*np.[u]int16*
,
*np.[u]int32*
,
*np.[u]int64*
```
python
...
...
@@ -76,6 +79,12 @@ rows, cols (,channels) = img.shape #channels only if color image
n_pixels
=
img
.
size
# = rows*cols*channels
img
.
dtype
```
-
Multiplication types
```
python
np
.
dot
(
x1
,
x2
)
# dot product of x1 and x2
np
.
multiply
(
x1
,
x2
)
# element wise multiplicatoin of x1 and x2
np
.
matmul
(
x1
,
x2
)
# matrix multiplication of x1 and x2
```
## Image manipulation
...
...
@@ -99,6 +108,8 @@ cv2.filter2D(img, ddepth=-1, w_gauss/np.sum(w_gauss))
cv2
.
filter2D
(
img
,
ddepth
=
cv2
.
CV_16S
,
w_sobel
)
# Normalize image between given minimum and maximum
cv2
.
normalize
(
img
,
NONE
,
min_val
,
max_val
,
cv2
.
NORM_MINMAX
)
# directly apply gaussian blur to image
cv2
.
GaussianBlur
(
img
.
astype
(
np
.
float64
),
(
n
,
n
),
sigma
)
```
### Frequency domain
...
...
@@ -155,6 +166,10 @@ plt.axvline(value, color="red") # vertical line at x="value"
plt
.
axhline
(
100
,
color
=
"
blue
"
)
# horizontal line at y=100
```
### Dots
```
python
plt
.
plot
(
pos
[
i
],
pos
[
j
],
'
ro
'
,
label
=
'
label1
'
)
# plot dots in red for position pos[i], pos[j]
```
# Misc
## Depth combinations
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment