Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing into 2nd highest peak might break #443

Open
cpaniaguam opened this issue Oct 9, 2024 · 0 comments
Open

Indexing into 2nd highest peak might break #443

cpaniaguam opened this issue Oct 9, 2024 · 0 comments

Comments

@cpaniaguam
Copy link
Member

In final2020.m the second highest peak is selected, but what if there is no second highest peak?

function find_reflectance_peaks(
reflectance_channel::Union{__T__,Matrix{Float64}};
possible_ice_threshold::Float64=Float64(75 / 255),
)::Int64
reflectance_channel[reflectance_channel .< possible_ice_threshold] .= 0 #75 / 255
_, counts = ImageContrastAdjustment.build_histogram(reflectance_channel)
locs, _ = Peaks.findmaxima(counts)
sort!(locs; rev=true)
return locs[2] # second greatest peak

In master.m this scenario is handled:

if size(peakLocs1,1)>2 && size(peakLocs2,1)>2 
        peak1=peakLocs1(2);
        peak2=peakLocs2(2);
        ice_b=find(tiles_ref1b>peak1);
        ice_c=find(tiles_ref1c>peak2);
        ice_labels = intersect(intersect(ice_a,ice_b),ice_c);
        nlabel=mode(double(tiles_new2(ice_labels)));
else
        nlabel=1;    
end

Essentially, it checks that more than 2 peaks were found and if that is not the case it makes nlabels equal to 1. It's not entirely clear to me why this needs to be the case but I thought about noting this as I prep the workflow that uses tiling for these purposes.

@tdivoll @danielmwatkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant