lab 3 finished

This commit is contained in:
pbiskup 2021-11-28 21:50:03 +01:00
parent 04016943d5
commit 0269d5c820
8 changed files with 99 additions and 0 deletions

8
lab3_zad3/.idea/.gitignore vendored Normal file
View 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

View 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>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View 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
lab3_zad3/.idea/misc.xml Normal file
View 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 (lab3_zad3)" project-jdk-type="Python SDK" />
</project>

View 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/lab3_zad3.iml" filepath="$PROJECT_DIR$/.idea/lab3_zad3.iml" />
</modules>
</component>
</project>

6
lab3_zad3/.idea/vcs.xml Normal file
View 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>

42
lab3_zad3/main.py Normal file
View File

@ -0,0 +1,42 @@
import cv2 as cv
def on_change(val):
pass
if __name__ == '__main__':
windowName = 'Canny edge detector'
cv.namedWindow(windowName, cv.WINDOW_NORMAL)
image = cv.imread("../img/lena.png", cv.IMREAD_COLOR)
kernelSizes = [(1, 1), (3, 3), (9, 9), (15, 15)]
blur_t = 'Blur'
low_threshold_t = 'Low Threshold'
high_threshold_t = 'High Threshold'
aperture_size_t = 'Aperture Size'
cv.createTrackbar(blur_t, windowName, 0, 3, on_change)
cv.createTrackbar(low_threshold_t, windowName, 0, 300, on_change)
cv.createTrackbar(high_threshold_t, windowName, 0, 300, on_change)
cv.createTrackbar(aperture_size_t, windowName, 3, 30, on_change)
cv.imshow(windowName, image)
while 1:
img = image.copy()
k = cv.waitKey(1) & 0xFF
if k == 27:
break
blur = cv.getTrackbarPos(blur_t, windowName)
low_threshold = cv.getTrackbarPos(low_threshold_t, windowName)
high_threshold = cv.getTrackbarPos(high_threshold_t, windowName)
aperture_size = cv.getTrackbarPos(aperture_size_t, windowName)
lena_blurred = cv.GaussianBlur(img, kernelSizes[blur], 0, 0)
edges = cv.Canny(lena_blurred, low_threshold, high_threshold, aperture_size)
cv.imshow(windowName, edges)
cv.destroyAllWindows()