lab6
This commit is contained in:
parent
dbcc613b64
commit
e395ad0e99
BIN
img/grabcut-result.png
Normal file
BIN
img/grabcut-result.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 545 KiB |
BIN
img/messi5.jpg
Normal file
BIN
img/messi5.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
BIN
img/pedestrians.jpg
Normal file
BIN
img/pedestrians.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 519 KiB |
8
lab6/.idea/.gitignore
vendored
Normal file
8
lab6/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
15
lab6/.idea/inspectionProfiles/Project_Default.xml
Normal file
15
lab6/.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="W29" />
|
||||||
|
<option value="E501" />
|
||||||
|
<option value="W29" />
|
||||||
|
<option value="E501" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
6
lab6/.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
lab6/.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
10
lab6/.idea/lab6.iml
Normal file
10
lab6/.idea/lab6.iml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
4
lab6/.idea/misc.xml
Normal file
4
lab6/.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (lab6)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
lab6/.idea/modules.xml
Normal file
8
lab6/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/lab6.iml" filepath="$PROJECT_DIR$/.idea/lab6.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
lab6/.idea/vcs.xml
Normal file
6
lab6/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
17
lab6/main.py
Normal file
17
lab6/main.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import cv2 as cv
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
img = cv.imread('../img/messi5.jpg', cv.IMREAD_COLOR)
|
||||||
|
|
||||||
|
mask = np.zeros(img.shape[:2], np.uint8)
|
||||||
|
bgdModel = np.zeros((1, 65), np.float64)
|
||||||
|
fgdModel = np.zeros((1, 65), np.float64)
|
||||||
|
rect = (50, 50, 450, 290)
|
||||||
|
cv.grabCut(img, mask, rect, bgdModel, fgdModel, 5, cv.GC_INIT_WITH_RECT)
|
||||||
|
mask2 = np.where((mask == 2) | (mask == 0), 0, 1).astype('uint8')
|
||||||
|
img = img * mask2[:, :, np.newaxis]
|
||||||
|
|
||||||
|
cv.imshow("image", img)
|
||||||
|
cv.waitKey()
|
||||||
|
cv.destroyAllWindows()
|
Loading…
Reference in New Issue
Block a user