Skip to content

Feature/lazy image #13

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ authors = ["IHP Systems R&D <[email protected]>"]
version = "0.6.0"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"

[compat]
ColorTypes = "0.11.0"
GeometryBasics = "0.4.1"
julia = "1"

Expand Down
1 change: 1 addition & 0 deletions src/ImageAnnotations.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module ImageAnnotations

using ColorTypes
using GeometryBasics

export AbstractConcept, AbstractConceptAttribute, CategoricalConceptAttribute, Concept
Expand Down
2 changes: 1 addition & 1 deletion src/abstract_image_annotator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ abstract type AbstractImageAnnotator{L, A <: AbstractImageAnnotation{L}} end

abstract type AbstractObjectAnnotator{L, T, A <: AbstractObjectAnnotation{L, T}} <: AbstractImageAnnotator{L, A} end

annotate(image, annotator::AbstractImageAnnotator) = error("No implementation for $(typeof(annotator))")
annotate(image::AbstractArray{<:Colorant,2}, annotator::AbstractImageAnnotator) = error("No implementation for $(typeof(annotator))")
23 changes: 23 additions & 0 deletions src/lazy_image.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
abstract type AbstractLazyImage{TPixel <: Colorant} end

struct LazyImageIOImage{TPixel} <: AbstractLazyImage{TPixel}
path::Union{String, Nothing}
image::Union{Array{TPixel, 2}, Nothing}
end

LazyImageIOImage{TPixel}(path::String) = LazyImageIOImage{TPixel}(path, nothing)

# Instance properties

Base.propertynames(::LazyImageIOImage) = fieldnames(LazyImageIOImage)

function Base.getproperty(image::LazyImageIOImage, name::Symbol)
if name == :image
if image.image === nothing
image.image = load(image.path)
end
return image.image
else
return getfield(image, name)
end
end
2 changes: 1 addition & 1 deletion src/static_image_annotator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ struct StaticObjectAnnotator{L, T <: Real, A <: AbstractObjectAnnotation{L, T}}
annotations::Vector{A}
end

function annotate(image, annotator::Union{StaticImageAnnotator, StaticObjectAnnotator})
function annotate(image::AbstractArray{<:Colorant,2}, annotator::Union{StaticImageAnnotator, StaticObjectAnnotator})
return annotator.annotations
end