diff --git a/Project.toml b/Project.toml index 9ab8fbe..f55a65a 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,12 @@ authors = ["IHP Systems R&D "] 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" diff --git a/src/ImageAnnotations.jl b/src/ImageAnnotations.jl index 521eab8..70622c5 100644 --- a/src/ImageAnnotations.jl +++ b/src/ImageAnnotations.jl @@ -1,5 +1,6 @@ module ImageAnnotations +using ColorTypes using GeometryBasics export AbstractConcept, AbstractConceptAttribute, CategoricalConceptAttribute, Concept diff --git a/src/abstract_image_annotator.jl b/src/abstract_image_annotator.jl index add1293..aaacd69 100644 --- a/src/abstract_image_annotator.jl +++ b/src/abstract_image_annotator.jl @@ -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))") diff --git a/src/lazy_image.jl b/src/lazy_image.jl new file mode 100644 index 0000000..a90cd66 --- /dev/null +++ b/src/lazy_image.jl @@ -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 diff --git a/src/static_image_annotator.jl b/src/static_image_annotator.jl index 067ef42..f2b3985 100644 --- a/src/static_image_annotator.jl +++ b/src/static_image_annotator.jl @@ -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