Implemented an experimental executable for all systems, fixed a few errors, implemented first try for a median filter for the slices in Julia
This commit is contained in:
parent
59630bdd95
commit
63c7428214
116
app.jl
116
app.jl
@ -36,6 +36,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
# Text field validations
|
# Text field validations
|
||||||
@in triqEnabled=false
|
@in triqEnabled=false
|
||||||
@in SpectraEnabled=false
|
@in SpectraEnabled=false
|
||||||
|
@in MFilterEnabled=false
|
||||||
# Dialogs
|
# Dialogs
|
||||||
@in warning_msg=false
|
@in warning_msg=false
|
||||||
@in CompareDialog=false
|
@in CompareDialog=false
|
||||||
@ -91,17 +92,21 @@ include("./julia_imzML_visual.jl")
|
|||||||
@out imgHeight=0
|
@out imgHeight=0
|
||||||
|
|
||||||
# Optical Image Overlay & Transparency
|
# Optical Image Overlay & Transparency
|
||||||
@in imgTrans = 1.0
|
@in imgTrans=1.0
|
||||||
@in progressOptical = false
|
@in progressOptical=false
|
||||||
@out btnOpticalDisable = true
|
@out btnOpticalDisable=true
|
||||||
@in btnOptical = false
|
@in btnOptical=false
|
||||||
@in btnOpticalT = false
|
@in btnOpticalT=false
|
||||||
@in opticalOverTriq = false
|
@in opticalOverTriq=false
|
||||||
|
@out imgRoute=""
|
||||||
|
|
||||||
# Messages to interface variables
|
# Messages to interface variables
|
||||||
@out msg=""
|
@out msg=""
|
||||||
@out msgimg=""
|
@out msgimg=""
|
||||||
@out msgtriq=""
|
@out msgtriq=""
|
||||||
|
# Reiteration of the messages under the image to know which spectra is being visualized
|
||||||
|
@out msgimgComp=""
|
||||||
|
@out msgtriqComp=""
|
||||||
|
|
||||||
# Saves the route where imzML and mzML files are located
|
# Saves the route where imzML and mzML files are located
|
||||||
@out full_route=""
|
@out full_route=""
|
||||||
@ -292,12 +297,10 @@ include("./julia_imzML_visual.jl")
|
|||||||
msg="File exists, Nmass=$(Nmass) Tol=$(Tol). Loading file will begin, please be patient."
|
msg="File exists, Nmass=$(Nmass) Tol=$(Tol). Loading file will begin, please be patient."
|
||||||
try
|
try
|
||||||
spectra=LoadImzml(full_route)
|
spectra=LoadImzml(full_route)
|
||||||
msg="File loaded. Creating Spectra with the specific mass and tolerance, please be patient."
|
println(typeof(spectra))
|
||||||
try
|
msg="File loaded. Creating spectra with the specific mass and tolerance, please be patient."
|
||||||
slice=GetMzSliceJl(spectra,Nmass,Tol)
|
slice=GetMzSliceJl(spectra,Nmass,Tol)
|
||||||
catch e
|
println(typeof(slice))
|
||||||
println("the error is in the slice: $e")
|
|
||||||
end
|
|
||||||
fig=CairoMakie.Figure(size=(150, 250)) # Container
|
fig=CairoMakie.Figure(size=(150, 250)) # Container
|
||||||
# Append a query string to force the image to refresh
|
# Append a query string to force the image to refresh
|
||||||
timestamp=string(time_ns())
|
timestamp=string(time_ns())
|
||||||
@ -307,14 +310,18 @@ include("./julia_imzML_visual.jl")
|
|||||||
warning_msg=true
|
warning_msg=true
|
||||||
else
|
else
|
||||||
image_path=joinpath("./public", "TrIQ_$(text_nmass).bmp")
|
image_path=joinpath("./public", "TrIQ_$(text_nmass).bmp")
|
||||||
valid_slice = false
|
valid_slice=false
|
||||||
while Tol <= 1.0 && !valid_slice
|
while Tol <= 1.0 && !valid_slice
|
||||||
try
|
try
|
||||||
slice = GetMzSliceJl(spectra, Nmass, Tol)
|
slice=GetMzSliceJl(spectra, Nmass, Tol)
|
||||||
sliceTriq = TrIQ(slice, colorLevel, triqProb)
|
sliceTriq=TrIQ(slice, colorLevel, triqProb)
|
||||||
valid_slice = true
|
println(typeof(sliceTriq))
|
||||||
|
if MFilterEnabled # If the Median filter is ON
|
||||||
|
sliceTriq=medianFilterjl(sliceTriq)
|
||||||
|
end
|
||||||
|
valid_slice=true
|
||||||
catch e
|
catch e
|
||||||
msg="Warning: insufficient tolerance, inputs modified to allow the creation of an image regardless = $Tol: $e"
|
msg="Warning: insufficient tolerance, inputs modified to allow the creation of an image regardless=$Tol: $e"
|
||||||
Tol += 0.1
|
Tol += 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -327,10 +334,10 @@ include("./julia_imzML_visual.jl")
|
|||||||
current_triq="TrIQ_$(text_nmass).bmp"
|
current_triq="TrIQ_$(text_nmass).bmp"
|
||||||
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Create colorbar
|
# Create colorbar
|
||||||
bound = julia_mzML_imzML.GetOutlierThres(slice, triqProb)
|
bound =julia_mzML_imzML.GetOutlierThres(slice, triqProb)
|
||||||
levels = range(bound[1],stop=bound[2], length=8)
|
levels=range(bound[1],stop=bound[2], length=8)
|
||||||
levels = vcat(levels, 2*levels[end]-levels[end-1])
|
levels=vcat(levels, 2*levels[end]-levels[end-1])
|
||||||
Colorbar(fig[1, 1], colormap=cgrad(:viridis, colorLevel, categorical=true), limits=(0, bound[2]),ticks=levels,tickformat=log_tick_formatter, label="Intensity", size = 25)
|
Colorbar(fig[1, 1], colormap=cgrad(:viridis, colorLevel, categorical=true), limits=(0, bound[2]),ticks=levels,tickformat=log_tick_formatter, label="Intensity", size=25)
|
||||||
save("public/colorbar_TrIQ_$(text_nmass).png", fig)
|
save("public/colorbar_TrIQ_$(text_nmass).png", fig)
|
||||||
colorbarT="/colorbar_TrIQ_$(text_nmass).png?t=$(timestamp)"
|
colorbarT="/colorbar_TrIQ_$(text_nmass).png?t=$(timestamp)"
|
||||||
# Get current colorbar
|
# Get current colorbar
|
||||||
@ -345,11 +352,14 @@ include("./julia_imzML_visual.jl")
|
|||||||
end
|
end
|
||||||
else # If we don't use TrIQ
|
else # If we don't use TrIQ
|
||||||
image_path=joinpath("./public", "MSI_$(text_nmass).bmp")
|
image_path=joinpath("./public", "MSI_$(text_nmass).bmp")
|
||||||
##sliceQuant=IntQuant(slice)
|
|
||||||
try
|
try
|
||||||
sliceQuant=IntQuantCl(slice,Int(colorLevel-1))
|
sliceQuant=IntQuantCl(slice,Int(colorLevel-1))
|
||||||
|
println(typeof(sliceQuant))
|
||||||
|
if MFilterEnabled # If the Median filter is ON
|
||||||
|
sliceQuant=medianFilterjl(sliceQuant)
|
||||||
|
end
|
||||||
catch e
|
catch e
|
||||||
println("the error is in the non triq slice: $e")
|
println("The error is in the non triq slice: $e")
|
||||||
end
|
end
|
||||||
sliceQuant=reverse(sliceQuant, dims=2)
|
sliceQuant=reverse(sliceQuant, dims=2)
|
||||||
SaveBitmapCl(joinpath("public", "MSI_$(text_nmass).bmp"),sliceQuant,ViridisPalette)
|
SaveBitmapCl(joinpath("public", "MSI_$(text_nmass).bmp"),sliceQuant,ViridisPalette)
|
||||||
@ -361,7 +371,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Create colorbar
|
# Create colorbar
|
||||||
levels=range(0,maximum(slice),length=8)
|
levels=range(0,maximum(slice),length=8)
|
||||||
Colorbar(fig[1, 1], colormap=cgrad(:viridis, colorLevel, categorical=true), limits=(0, maximum(slice)),ticks=levels,tickformat=log_tick_formatter, label="Intensity", size = 25)
|
Colorbar(fig[1, 1], colormap=cgrad(:viridis, colorLevel, categorical=true), limits=(0, maximum(slice)),ticks=levels,tickformat=log_tick_formatter, label="Intensity", size=25)
|
||||||
save("public/colorbar_MSI_$(text_nmass).png", fig)
|
save("public/colorbar_MSI_$(text_nmass).png", fig)
|
||||||
colorbar="/colorbar_MSI_$(text_nmass).png?t=$(timestamp)"
|
colorbar="/colorbar_MSI_$(text_nmass).png?t=$(timestamp)"
|
||||||
# Get current colorbar
|
# Get current colorbar
|
||||||
@ -390,7 +400,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
end
|
end
|
||||||
btnStartDisable=false
|
btnStartDisable=false
|
||||||
btnPlotDisable=false
|
btnPlotDisable=false
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
if isfile(full_routeMz)
|
if isfile(full_routeMz)
|
||||||
# We enable coord search and spectra plot creation
|
# We enable coord search and spectra plot creation
|
||||||
btnSpectraDisable=false
|
btnSpectraDisable=false
|
||||||
@ -540,7 +550,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImg, plotlayoutImg, imgWidth, imgHeight=loadImgPlot(imgInt)
|
plotdataImg, plotlayoutImg, imgWidth, imgHeight=loadImgPlot(imgInt)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImg=[traceImg]
|
plotdataImg=[traceImg]
|
||||||
@ -567,7 +577,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImg, plotlayoutImg, imgWidth, imgHeight=loadImgPlot(imgInt)
|
plotdataImg, plotlayoutImg, imgWidth, imgHeight=loadImgPlot(imgInt)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImg=[traceImg]
|
plotdataImg=[traceImg]
|
||||||
@ -595,7 +605,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgT, plotlayoutImgT, imgWidth, imgHeight=loadImgPlot(imgIntT)
|
plotdataImgT, plotlayoutImgT, imgWidth, imgHeight=loadImgPlot(imgIntT)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgT=[traceImg]
|
plotdataImgT=[traceImg]
|
||||||
@ -622,7 +632,7 @@ include("./julia_imzML_visual.jl")
|
|||||||
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgT, plotlayoutImgT, imgWidth, imgHeight=loadImgPlot(imgIntT)
|
plotdataImgT, plotlayoutImgT, imgWidth, imgHeight=loadImgPlot(imgIntT)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgT=[traceImg]
|
plotdataImgT=[traceImg]
|
||||||
@ -648,14 +658,14 @@ include("./julia_imzML_visual.jl")
|
|||||||
|
|
||||||
text_nmass=replace(current_msiComp, "MSI_" => "")
|
text_nmass=replace(current_msiComp, "MSI_" => "")
|
||||||
text_nmass=replace(text_nmass, ".bmp" => "")
|
text_nmass=replace(text_nmass, ".bmp" => "")
|
||||||
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgimgComp="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgComp, plotlayoutImgComp, _, _=loadImgPlot(imgIntComp)
|
plotdataImgComp, plotlayoutImgComp, _, _=loadImgPlot(imgIntComp)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgComp=[traceImg]
|
plotdataImgComp=[traceImg]
|
||||||
msgimg=""
|
msgimgComp=""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -676,14 +686,14 @@ include("./julia_imzML_visual.jl")
|
|||||||
|
|
||||||
text_nmass=replace(current_msiComp, "MSI_" => "")
|
text_nmass=replace(current_msiComp, "MSI_" => "")
|
||||||
text_nmass=replace(text_nmass, ".bmp" => "")
|
text_nmass=replace(text_nmass, ".bmp" => "")
|
||||||
msgimg="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgimgComp="Image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgComp, plotlayoutImgComp, _, _=loadImgPlot(imgIntComp)
|
plotdataImgComp, plotlayoutImgComp, _, _=loadImgPlot(imgIntComp)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgComp=[traceImg]
|
plotdataImgComp=[traceImg]
|
||||||
msgimg=""
|
msgimgComp=""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -704,14 +714,14 @@ include("./julia_imzML_visual.jl")
|
|||||||
|
|
||||||
text_nmass=replace(current_triqComp, "TrIQ_" => "")
|
text_nmass=replace(current_triqComp, "TrIQ_" => "")
|
||||||
text_nmass=replace(text_nmass, ".bmp" => "")
|
text_nmass=replace(text_nmass, ".bmp" => "")
|
||||||
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgtriqComp="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgTComp, plotlayoutImgTComp, _, _=loadImgPlot(imgIntTComp)
|
plotdataImgTComp, plotlayoutImgTComp, _, _=loadImgPlot(imgIntTComp)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgTComp=[traceImg]
|
plotdataImgTComp=[traceImg]
|
||||||
msgtriq=""
|
msgtriqComp=""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -732,14 +742,14 @@ include("./julia_imzML_visual.jl")
|
|||||||
|
|
||||||
text_nmass=replace(current_triqComp, "TrIQ_" => "")
|
text_nmass=replace(current_triqComp, "TrIQ_" => "")
|
||||||
text_nmass=replace(text_nmass, ".bmp" => "")
|
text_nmass=replace(text_nmass, ".bmp" => "")
|
||||||
msgtriq="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
msgtriqComp="TrIQ image with the Nmass of $(replace(text_nmass, "_" => "."))"
|
||||||
# Process the image in the function
|
# Process the image in the function
|
||||||
plotdataImgTComp, plotlayoutImgTComp, _, _=loadImgPlot(imgIntTComp)
|
plotdataImgTComp, plotlayoutImgTComp, _, _=loadImgPlot(imgIntTComp)
|
||||||
btnOpticalDisable = false
|
btnOpticalDisable=false
|
||||||
else
|
else
|
||||||
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
traceImg=PlotlyBase.heatmap(x=[], y=[])
|
||||||
plotdataImgTComp=[traceImg]
|
plotdataImgTComp=[traceImg]
|
||||||
msgtriq=""
|
msgtriqComp=""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -922,28 +932,28 @@ include("./julia_imzML_visual.jl")
|
|||||||
spectracoords=reshape(plotdata, 1, length(plotdata))
|
spectracoords=reshape(plotdata, 1, length(plotdata))
|
||||||
# Extract x and y values from data_click
|
# Extract x and y values from data_click
|
||||||
cursor_data=data_click["cursor"]
|
cursor_data=data_click["cursor"]
|
||||||
x_value = cursor_data["x"]
|
x_value=cursor_data["x"]
|
||||||
y_value = cursor_data["y"]
|
y_value=cursor_data["y"]
|
||||||
|
|
||||||
# Find the minimum x-value in spectracoords
|
# Find the minimum x-value in spectracoords
|
||||||
min_x_value = minimum([minimum(val[:x]) for val in spectracoords if !isempty(val[:x])])
|
min_x_value=minimum([minimum(val[:x]) for val in spectracoords if !isempty(val[:x])])
|
||||||
# Adjust x_value and spectracoords x-values to start from 0
|
# Adjust x_value and spectracoords x-values to start from 0
|
||||||
adjusted_x_value = x_value - min_x_value
|
adjusted_x_value=x_value - min_x_value
|
||||||
|
|
||||||
closest_distance = Inf
|
closest_distance=Inf
|
||||||
for val in spectracoords
|
for val in spectracoords
|
||||||
adjusted_x = val[:x] .- min_x_value
|
adjusted_x=val[:x] .- min_x_value
|
||||||
start_idx = findfirst(x -> x >= adjusted_x_value - 20, adjusted_x)
|
start_idx=findfirst(x -> x >= adjusted_x_value - 20, adjusted_x)
|
||||||
end_idx = findlast(x -> x <= adjusted_x_value + 20, adjusted_x)
|
end_idx=findlast(x -> x <= adjusted_x_value + 20, adjusted_x)
|
||||||
|
|
||||||
if start_idx !== nothing && end_idx !== nothing
|
if start_idx !== nothing && end_idx !== nothing
|
||||||
for i in start_idx:end_idx
|
for i in start_idx:end_idx
|
||||||
spectra_x = adjusted_x[i]
|
spectra_x=adjusted_x[i]
|
||||||
spectra_y = val[:y][i]
|
spectra_y=val[:y][i]
|
||||||
distance = sqrt((spectra_x - adjusted_x_value)^2 + (spectra_y - y_value)^2)
|
distance=sqrt((spectra_x - adjusted_x_value)^2 + (spectra_y - y_value)^2)
|
||||||
if distance < closest_distance
|
if distance < closest_distance
|
||||||
closest_distance = distance
|
closest_distance=distance
|
||||||
Nmass = round(spectra_x + min_x_value, digits=2)
|
Nmass=round(spectra_x + min_x_value, digits=2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -339,7 +339,7 @@
|
|||||||
<q-img id="colorbar" class="q-ma-none q-pa-none" :src="colorbarComp"></q-img>
|
<q-img id="colorbar" class="q-ma-none q-pa-none" :src="colorbarComp"></q-img>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>{{msgimg}}</p>
|
<p>{{msgimgComp}}</p>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
|
|
||||||
<q-tab-panel name="tab1">
|
<q-tab-panel name="tab1">
|
||||||
@ -359,7 +359,7 @@
|
|||||||
<q-img id="colorbar" class="q-ma-none q-pa-none" :src="colorbarTComp"></q-img>
|
<q-img id="colorbar" class="q-ma-none q-pa-none" :src="colorbarTComp"></q-img>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>{{msgtriq}}</p>
|
<p>{{msgtriqComp}}</p>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
<q-tab-panel name="tab2">
|
<q-tab-panel name="tab2">
|
||||||
<!-- Content for Tab 2 -->
|
<!-- Content for Tab 2 -->
|
||||||
|
|||||||
18
executable.sh
Executable file
18
executable.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
command="julia --project=. start_MSI_GUI.jl"
|
||||||
|
|
||||||
|
case "$OSTYPE" in
|
||||||
|
linux*)
|
||||||
|
$command
|
||||||
|
;;
|
||||||
|
darwin*)
|
||||||
|
$command
|
||||||
|
;;
|
||||||
|
cygwin*|msys*|win32)
|
||||||
|
julia --project=. start_MSI_GUI.jl
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported OS"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@ -384,3 +384,28 @@ function log_tick_formatter(values::Vector{Float64})
|
|||||||
return map((v, e) -> e == 0 ? "$(round(v, sigdigits=2))" : "$(round(v, sigdigits=2))x10" * Makie.UnicodeFun.to_superscript(e), formValues, exponents)
|
return map((v, e) -> e == 0 ? "$(round(v, sigdigits=2))" : "$(round(v, sigdigits=2))x10" * Makie.UnicodeFun.to_superscript(e), formValues, exponents)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Median filter: an adaptation of the R medianfilter, which averages the matrix
|
||||||
|
# with the close pixels just from the sides to reduce noise.
|
||||||
|
# This one in particular is a midpoint fiter from a 3x3 neighbour area
|
||||||
|
function medianFilterjl(pixMap)
|
||||||
|
width, height = size(pixMap)
|
||||||
|
target = zeros(eltype(pixMap), height, width)
|
||||||
|
println("Matrix Dimensions: ", size(pixMap))
|
||||||
|
|
||||||
|
for j in 2:(width-1)
|
||||||
|
for i in 2:(height-1)
|
||||||
|
println("Current Indices: i = $i, j = $j")
|
||||||
|
neighbors = []
|
||||||
|
for dj in max(1, j-1):min(width, j+1)
|
||||||
|
for di in max(1, i-1):min(height, i+1)
|
||||||
|
push!(neighbors, pixMap[di, dj])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
target[i, j] = median(neighbors)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return target
|
||||||
|
|
||||||
|
end
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 285 KiB |
Loading…
x
Reference in New Issue
Block a user