Created
December 31, 2019 06:36
-
-
Save Akshat-mehrotra/1cbcb2cb28699d1078d1881121b4ca3b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Benchmarking with JuliaImages\n", | |
"We'll run every test 10 times. \n", | |
"Then take the mean of the 10 values to get the most accurate value" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0-element Array{Any,1}" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"using Images\n", | |
"using Statistics\n", | |
"\n", | |
"folder = \"G:\\\\Book-Cover-Test\\\\img1.png\"\n", | |
"img = Gray.(load(folder))\n", | |
"treading=[]\n", | |
"tsaving=[]\n", | |
"tcanny=[]\n", | |
"tharris=[]\n", | |
"tresize=[]\n", | |
"tintegral=[]\n", | |
"ttophat=[]\n", | |
"tblur=[]\n", | |
"tpyramid=[]\n", | |
"tmean=[]\n", | |
"tmin=[]\n", | |
"ttofloat=[]\n", | |
"tentropy=[]" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test reading" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0225" | |
] | |
}, | |
"execution_count": 33, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"k = 1\n", | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" load(folder)\n", | |
" end\n", | |
" push!(treading,t)\n", | |
"end\n", | |
"round(mean(treading), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Saving" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.3131" | |
] | |
}, | |
"execution_count": 36, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" save(folder, img)\n", | |
" end\n", | |
" push!(tsaving,t)\n", | |
"end\n", | |
"round(mean(tsaving), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Canny Edge Detection" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.164" | |
] | |
}, | |
"execution_count": 37, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" canny(img, (Percentile(80), Percentile(20)), 2.4)\n", | |
" end\n", | |
" push!(tcanny,t)\n", | |
"end\n", | |
"round(mean(tcanny), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Resize" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 39, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0074" | |
] | |
}, | |
"execution_count": 39, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" imresize(img, 10,10)\n", | |
" end\n", | |
" push!(tresize,t)\n", | |
"end\n", | |
"round(mean(tresize), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Integral of Image" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 40, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0124" | |
] | |
}, | |
"execution_count": 40, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" integral_image(img)\n", | |
" end\n", | |
" push!(tintegral,t)\n", | |
"end\n", | |
"round(mean(tintegral), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Harris Corner Detection" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 41, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.1655" | |
] | |
}, | |
"execution_count": 41, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" harris(img)\n", | |
" end\n", | |
" push!(tharris,t)\n", | |
"end\n", | |
"round(mean(tharris), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test TopHat Filtering" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 42, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0121" | |
] | |
}, | |
"execution_count": 42, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" tophat(img)\n", | |
" end\n", | |
" push!(ttophat,t)\n", | |
"end\n", | |
"round(mean(ttophat), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Gaussian Blur" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 43, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0815" | |
] | |
}, | |
"execution_count": 43, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" imfilter(img, Kernel.gaussian((3,3))) \n", | |
" end\n", | |
" push!(tblur,t)\n", | |
"end\n", | |
"round(mean(tblur), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Testing Image Mean" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0071" | |
] | |
}, | |
"execution_count": 44, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" meanfinite(img, 1)\n", | |
" end\n", | |
" push!(tmean,t)\n", | |
"end\n", | |
"round(mean(tmean), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Testing Image Minimum" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0005" | |
] | |
}, | |
"execution_count": 45, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" minfinite(img,)\n", | |
" end\n", | |
" push!(tmin,t)\n", | |
"end\n", | |
"round(mean(tmin), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Image Changing Image To Float" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0021" | |
] | |
}, | |
"execution_count": 46, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" float(img)\n", | |
" end\n", | |
" push!(ttofloat,t)\n", | |
"end\n", | |
"round(mean(ttofloat), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Image Entropy" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 47, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0381" | |
] | |
}, | |
"execution_count": 47, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" entropy(img)\n", | |
" end\n", | |
" push!(tentropy,t)\n", | |
"end\n", | |
"round(mean(tentropy), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test Gaussian Pyramid" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 48, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.0642" | |
] | |
}, | |
"execution_count": 48, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"for i in 1:10\n", | |
" t = @elapsed begin\n", | |
" gaussian_pyramid(img, 12, 1.5, 2.5)\n", | |
" end\n", | |
" push!(tpyramid,t)\n", | |
"end\n", | |
"round(mean(tpyramid), digits=4)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"@webio": { | |
"lastCommId": null, | |
"lastKernelId": null | |
}, | |
"kernelspec": { | |
"display_name": "Julia 1.0.5", | |
"language": "julia", | |
"name": "julia-1.0" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.0.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment