Skip to content

Commit 19e23a4

Browse files
authored
Merge pull request #638 from microsoft/staging
Syncing master <-> staging branches
2 parents d78498a + 3dc96e0 commit 19e23a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1229
-81
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
1212
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
1313
- [ ] I have followed the [contribution guidelines](../CONTRIBUTING.md) and code style for this project.
14+
- [ ] This branch is created from `staging` and not `master`.
15+
- [ ] This PR is being made to `staging` and not `master`.
16+
- [ ] I will squash merge this PR into `staging`.
1417
- [ ] I have added tests covering my contributions.
1518
- [ ] I have updated the documentation accordingly.
16-
- [ ] This PR is being made to `staging` and not `master`
17-
- [ ] I will squash merge this PR into `staging`

NOTICE.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,31 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
525525
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
526526
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
527527
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
528-
SOFTWARE.
528+
SOFTWARE.
529+
530+
--
531+
532+
https://github.com/ifzhang/FairMOT
533+
534+
535+
MIT License
536+
537+
Copyright (c) 2020 YifuZhang
538+
539+
Permission is hereby granted, free of charge, to any person obtaining a copy
540+
of this software and associated documentation files (the "Software"), to deal
541+
in the Software without restriction, including without limitation the rights
542+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
543+
copies of the Software, and to permit persons to whom the Software is
544+
furnished to do so, subject to the following conditions:
545+
546+
The above copyright notice and this permission notice shall be included in all
547+
copies or substantial portions of the Software.
548+
549+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
550+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
551+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
552+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
553+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
554+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
555+
SOFTWARE.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
In recent years, we've see an extra-ordinary growth in Computer Vision, with applications in face recognition, image understanding, search, drones, mapping, semi-autonomous and autonomous vehicles. A key part to many of these applications are visual recognition tasks such as image classification, object detection and image similarity.
77

8-
This repository provides examples and best practice guidelines for building computer vision systems. The goal of this repository is to build a comprehensive set of tools and examples that leverage recent advances in Computer Vision algorithms, neural architectures, and operationalizing such systems. Rather than creating implementions from scratch, we draw from existing state-of-the-art libraries and build additional utility around loading image data, optimizing and evaluating models, and scaling up to the cloud. In addition, having worked in this space for many years, we aim to answer common questions, point out frequently observed pitfalls, and show how to use the cloud for training and deployment.
8+
This repository provides examples and best practice guidelines for building computer vision systems. The goal of this repository is to build a comprehensive set of tools and examples that leverage recent advances in Computer Vision algorithms, neural architectures, and operationalizing such systems. Rather than creating implementations from scratch, we draw from existing state-of-the-art libraries and build additional utility around loading image data, optimizing and evaluating models, and scaling up to the cloud. In addition, having worked in this space for many years, we aim to answer common questions, point out frequently observed pitfalls, and show how to use the cloud for training and deployment.
99

1010
We hope that these examples and utilities can significantly reduce the “time to market” by simplifying the experience from defining the business problem to development of solution by orders of magnitude. In addition, the example notebooks would serve as guidelines and showcase best practices and usage of the tools in a wide variety of languages.
1111

@@ -37,7 +37,7 @@ notebooks in this repo. Once your environment is setup, navigate to the
3737

3838
Alternatively, we support Binder
3939
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/PatrickBue/computervision-recipes/master?filepath=scenarios%2Fclassification%2F01_training_introduction_BINDER.ipynb)
40-
which makes it easy to try one of our notebooks in a web-browser simply by following this link. However, Binder is free, and as as result only comes with limited CPU compute power and without GPU support. Expect the notebook to run very slowly (this is somewhat improved by reducing image resolution to e.g. 60 pixels but at the cost of low accuracies).
40+
which makes it easy to try one of our notebooks in a web-browser simply by following this link. However, Binder is free, and as a result only comes with limited CPU compute power and without GPU support. Expect the notebook to run very slowly (this is somewhat improved by reducing image resolution to e.g. 60 pixels but at the cost of low accuracies).
4141

4242
## Scenarios
4343

contrib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Each project should live in its own subdirectory ```/contrib/<project>``` and co
1010
|---|---|---|
1111
| [Crowd counting](crowd_counting) | Counting the number of people in low-crowd-density (e.g. less than 10 people) and high-crowd-density (e.g. thousands of people) scenarios. | [![Build Status](https://dev.azure.com/team-sharat/crowd-counting/_apis/build/status/lixzhang.cnt?branchName=lixzhang%2Fsubmodule-rev3)](https://dev.azure.com/team-sharat/crowd-counting/_build/latest?definitionId=49&branchName=lixzhang%2Fsubmodule-rev3)|
1212
| [Action Recognition with I3D](action_recognition) | Action recognition to identify video/webcam footage from what actions are performed (e.g. "running", "opening a bottle") and at what respective start/end times. Please note, that we also have a R(2+1)D implementation of action recognition that you can find under [scenarios](../sceanrios).| |
13+
| [Document Image Binarization](binarization) | Binarization is a technique to segment foreground from the background pixels. A simple technique for binarization is thresholding of gray-level or color document scanned images.| |
1314

1415
## Tools
1516
| Directory | Project description | Build status (optional) |

contrib/binarization/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binarization
2+
Binarization is a technique to segment foreground from the background pixels. A simple technique for binarization is thresholding of gray-level or color document scanned images.
3+
## At a glance
4+
5+
This binarization technique is an improvement over Sauvola's binarization technique. In this work, we improve the existing Sauvola's binarization technique by preserving more foreground information in the binarized document-images. In order to achieve this, we introduce a confidence score for the background pixels.
6+
7+
### Input images
8+
9+
<img src="./confidence_based_Sauvola_binarization/test_images/2.jpeg" width="33%"> </img>
10+
<img src="./confidence_based_Sauvola_binarization/test_images/10.jpeg" width="33%"> </img>
11+
<img src="./confidence_based_Sauvola_binarization/test_images/new1.jpg" width="33%"> </img>
12+
13+
### Binary outputs
14+
15+
<img src="./confidence_based_Sauvola_binarization/results/2_bin_new.png" width="33%"> </img>
16+
<img src="./confidence_based_Sauvola_binarization/results/10_bin_new.png" width="33%"> </img>
17+
<img src="./confidence_based_Sauvola_binarization/results/new1_bin_new.png" width="33%"> </img>

contrib/binarization/confidence_based_Sauvola_binarization/Modified-Sauvola_Binarization.ipynb

Lines changed: 213 additions & 0 deletions
Large diffs are not rendered by default.
Binary file not shown.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'''
2+
@author: Soumyadeep Dey
3+
email:Soumyadeep.Dey@microsoft.com
4+
Date: October 2020
5+
cite: https://drive.google.com/file/d/1D3CyI5vtodPJeZaD2UV5wdcaIMtkBbdZ/view?usp=sharing
6+
'''
7+
8+
# importing required libraries
9+
import numpy as np
10+
import cv2
11+
from skimage.filters import threshold_sauvola
12+
13+
14+
def SauvolaModBinarization(image,n1=51,n2=51,k1=0.3,k2=0.3,default=True):
15+
'''
16+
Binarization using Sauvola's algorithm
17+
@name : SauvolaModBinarization
18+
parameters
19+
@param image (numpy array of shape (3/1) of type np.uint8): color or gray scale image
20+
optional parameters
21+
@param n1 (int) : window size for running sauvola during the first pass
22+
@param n2 (int): window size for running sauvola during the second pass
23+
@param k1 (float): k value corresponding to sauvola during the first pass
24+
@param k2 (float): k value corresponding to sauvola during the second pass
25+
@param default (bool) : bollean variable to set the above parameter as default.
26+
27+
@param default is set to True : thus default values of the above optional parameters (n1,n2,k1,k2) are set to
28+
n1 = 5 % of min(image height, image width)
29+
n2 = 10 % of min(image height, image width)
30+
k1 = 0.5
31+
k2 = 0.5
32+
Returns
33+
@return A binary image of same size as @param image
34+
35+
@cite https://drive.google.com/file/d/1D3CyI5vtodPJeZaD2UV5wdcaIMtkBbdZ/view?usp=sharing
36+
'''
37+
38+
if(default):
39+
n1 = int(0.05*min(image.shape[0],image.shape[1]))
40+
if (n1%2==0):
41+
n1 = n1+1
42+
n2 = int(0.1*min(image.shape[0],image.shape[1]))
43+
if (n2%2==0):
44+
n2 = n2+1
45+
k1 = 0.5
46+
k2 = 0.5
47+
if(image.ndim==3):
48+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
49+
else:
50+
gray = np.copy(image)
51+
T1 = threshold_sauvola(gray, window_size=n1,k=k1)
52+
max_val = np.amax(gray)
53+
min_val = np.amin(gray)
54+
C = np.copy(T1)
55+
C = C.astype(np.float32)
56+
C[gray > T1] = (gray[gray > T1] - T1[gray > T1])/(max_val - T1[gray > T1])
57+
C[gray <= T1] = 0
58+
C = C * 255.0
59+
new_in = np.copy(C.astype(np.uint8))
60+
T2 = threshold_sauvola(new_in, window_size=n2,k=k2)
61+
binary = np.copy(gray)
62+
binary[new_in <= T2] = 0
63+
binary[new_in > T2] = 255
64+
return binary
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Binarization
2+
Binarization is a technique to segment foreground from the background pixels. A simple technique for binarization is thresholding of gray-level or color document scanned images.
3+
## At a glance
4+
5+
This binarization technique is an improvement over Sauvola's binarization technique. In this work, we improve the existing Sauvola's binarization technique by preserving more foreground information in the binarized document-images. In order to achieve this, we introduce a confidence score for the background pixels.
6+
7+
### Input images
8+
9+
<img src="./test_images/2.jpeg" width="33%"> </img>
10+
<img src="./test_images/10.jpeg" width="33%"> </img>
11+
<img src="./test_images/new1.jpg" width="33%"> </img>
12+
13+
### Sauvola outputs
14+
15+
<img src="./results/2_bin_old.png" width="33%"> </img>
16+
<img src="./results/10_bin_old.png" width="33%"> </img>
17+
<img src="./results/new1_bin_old.png" width="33%"> </img>
18+
19+
### Confidence based Sauvola outputs
20+
21+
<img src="./results/2_bin_new.png" width="33%"> </img>
22+
<img src="./results/10_bin_new.png" width="33%"> </img>
23+
<img src="./results/new1_bin_new.png" width="33%"> </img>
24+
25+
## Reference
26+
27+
For details refer to this [paper](./ModifiedSauvola.pdf)
28+
29+
30+
31+
32+
## Setup
33+
34+
### Dependencies
35+
- python 3.7
36+
- numpy 1.16
37+
- opencv 4.2
38+
- skimage 0.17
39+
40+
41+
### Example
42+
43+
Sample example of the usage of the said binarization technique can be found in this [notebook](./Modified-Sauvola_Binarization.ipynb).
218 KB
Loading

0 commit comments

Comments
 (0)