epredia

package module
v0.0.0-...-0e08d8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

README

epredia

Image viewer for scanned slides

Documentation

Index

Constants

This section is empty.

Variables

View Source
var YCbCrSlicer = &ImSlicer[uint8, *image.YCbCr]{
	ColorModel: color.YCbCrModel,
	SliceFromImage: func(im *image.YCbCr, x, y int) []uint8 {
		pix := im.YCbCrAt(x, y)
		return []uint8{pix.Y, pix.Cb, pix.Cr}
	},
	SliceToColor: func(sl []uint8) color.Color {
		return color.YCbCr{sl[0], sl[1], sl[2]}
	},
	TypeMin: 0,
	TypeMax: 255,
}

Functions

func Blur

func Blur(im [][]complex128, factor int) [][]complex128

Blur the image by performing a box filter. The box will begin at a position 1/factor from the edge in each direction This function takes and receives complex types since we will have to copy the values from the source array anyways, might as well do the conversion then.

func GetRelative

func GetRelative(im image.Image, x, y int) color.Color

Get a pixel at a position relative to the image's upper left hand corner

func ImSize

func ImSize(im image.Image) (int, int)

Get the size of an image

func NewImageWindow

func NewImageWindow(ourwindow fyne.Window, ti *TiledImage, lowresimage image.Image, uicolor color.Color)

build the ui and add it to a canvas. we will take the heavily downsampled image as an argument so that it can be pre-computed. If lowresimage is nil it will be computed here

Types

type ColorComponent

type ColorComponent interface {
	uint8 | uint16 | uint32 | uint64
}

Base types which could represent a component of a color

type CroppedImage

type CroppedImage struct {
	Image   image.Image
	Indices [2][2]int
}

Struct to represent a cropped image

func (*CroppedImage) At

func (cr *CroppedImage) At(x, y int) color.Color

func (*CroppedImage) Bounds

func (cr *CroppedImage) Bounds() image.Rectangle

func (*CroppedImage) ColorModel

func (cr *CroppedImage) ColorModel() color.Model

type DSImage

type DSImage interface {
	image.Image
	Downsample(factor int) DSImage
	Mean() DSImage //reduce to one pixel
}

Interface representing an image that can be downsampled

func NewDSImage

func NewDSImage(im image.Image) (DSImage, error)

Build a new MatImage from an image.Image

type ImSlicer

type ImSlicer[T ColorComponent, I image.Image] struct {
	ColorModel     color.Model
	SliceFromImage func(im I, x, y int) []T //convert a pixel to a slice
	SliceToColor   func([]T) color.Color    //pixel from slice
	TypeMin        int                      //what is the minimum value of T
	TypeMax        int                      //what is the maximum value of T
}

Struct to define conversions of pixels to and from slices

type MatImage

type MatImage[T ColorComponent] struct {
	Model        color.Model
	Width        int
	Height       int
	PixelMat     [][][]T               //index [x,y,channel]
	SliceToColor func([]T) color.Color //we'll copy the last three from ImSlicer
	TypeMin      int                   //what is the minimum value of T
	TypeMax      int                   //what is the maximum value of T
}

A struct which stores colors as slices of samples

func (*MatImage[T]) At

func (mi *MatImage[T]) At(x, y int) color.Color

func (*MatImage[T]) Bounds

func (mi *MatImage[T]) Bounds() image.Rectangle

func (*MatImage[T]) ColorModel

func (mi *MatImage[T]) ColorModel() color.Model

implement image.Image for MatImage

func (*MatImage[T]) Downsample

func (mi *MatImage[T]) Downsample(factor int) DSImage

Implement DSImage for MatImage

func (*MatImage[T]) Mean

func (mi *MatImage[T]) Mean() DSImage

type MosaicImage

type MosaicImage struct {
	TileWidth, TileHeight int
	NTileX, NTileY        int
	TileColorModel        color.Model
	Tiles                 [][]DSImage
}

An image made up of a bunch of tiled sub images.

func (*MosaicImage) At

func (mi *MosaicImage) At(x, y int) color.Color

func (*MosaicImage) Bounds

func (mi *MosaicImage) Bounds() image.Rectangle

func (*MosaicImage) ColorModel

func (mi *MosaicImage) ColorModel() color.Model

type ScaleOverlay

type ScaleOverlay struct {
	BaseImage   image.Image
	BarLengthCm float64
	ImageRes    float64 //in x direction, px per cm
	BarColor    color.Color
	// contains filtered or unexported fields
}

overlay a scalebar on an image

func OverlayScalebar

func OverlayScalebar(im image.Image, barlength float64, res float64, barcolor color.Color) *ScaleOverlay

Overlay a scale bar on an image. `barlength` should be the length of the scalebar in cm. `res` should be the x resolution of the image in px per cm

func (*ScaleOverlay) At

func (so *ScaleOverlay) At(x, y int) color.Color

func (*ScaleOverlay) Bounds

func (so *ScaleOverlay) Bounds() image.Rectangle

func (*ScaleOverlay) ColorModel

func (so *ScaleOverlay) ColorModel() color.Model

type TiledImage

type TiledImage struct {
	Width      uint
	Length     uint
	TileWidth  uint
	TileLength uint
	XRes       float64 //resolutions
	YRes       float64
	ResUnit    string //cm in or au
	NTileX     int    //number of tiles in each dimension
	NTileY     int
	TileBytes  [][][]byte //jpeg compressed tile images
}

A type representing a large tiled tiff

func NewTiledImage

func NewTiledImage(f *os.File) (*TiledImage, error)

Build a new TiledImage object from an os.File

func (*TiledImage) MaterializeAll

func (ti *TiledImage) MaterializeAll(maxsizex, maxsizey int) *MosaicImage

Materialize an entire TiledImage. we will assume all tiles have the same colormodel. If maxsizex and/or maxsizey are not zero the image will be downsampled to fit

func (*TiledImage) MaterializeMosaic

func (ti *TiledImage) MaterializeMosaic(i0, i1, j0, j1, maxsizex, maxsizey int) *MosaicImage

Make a new MosaicImage from a subset of our tiles corresponding to `ti.TileBytes[i0:i1][j0:j1]` we will assume all tiles have the same colormodel. If maxsizex and/or maxsizey are not zero the image will be downsampled to fit

func (*TiledImage) MaterializeTile

func (im *TiledImage) MaterializeTile(i, j int) (image.Image, error)

Method to materialize the tile at a given index as an image. `i` indexes in the column (x) direction and j indexes rows (y)

func (*TiledImage) QuickMaterialize

func (ti *TiledImage) QuickMaterialize(i0, i1, j0, j1 int) *MosaicImage

Quickly materialize a TiledImage by reducing each tile to one pixel by averaging

func (*TiledImage) QuickMaterializeAll

func (ti *TiledImage) QuickMaterializeAll() *MosaicImage

Materialize an entire TiledImage via [QuickMaterialize] we will assume all tiles have the same colormodel. If maxsizex and/or maxsizey are not zero the image will be downsampled to fit

Directories

Path Synopsis
cmd
goepredia command
internal
image/bmp
Package bmp implements a BMP image decoder and encoder.
Package bmp implements a BMP image decoder and encoder.
image/ccitt
Package ccitt implements a CCITT (fax) image decoder.
Package ccitt implements a CCITT (fax) image decoder.
image/colornames
Package colornames provides named colors as defined in the SVG 1.1 spec.
Package colornames provides named colors as defined in the SVG 1.1 spec.
image/draw
Package draw provides image composition functions.
Package draw provides image composition functions.
image/font
Package font defines an interface for font faces, for drawing text on an image.
Package font defines an interface for font faces, for drawing text on an image.
image/font/basicfont
Package basicfont provides fixed-size font faces.
Package basicfont provides fixed-size font faces.
image/font/gofont/gobold
Package gobold provides the "Go Bold" TrueType font from the Go font family.
Package gobold provides the "Go Bold" TrueType font from the Go font family.
image/font/gofont/gobolditalic
Package gobolditalic provides the "Go Bold Italic" TrueType font from the Go font family.
Package gobolditalic provides the "Go Bold Italic" TrueType font from the Go font family.
image/font/gofont/goitalic
Package goitalic provides the "Go Italic" TrueType font from the Go font family.
Package goitalic provides the "Go Italic" TrueType font from the Go font family.
image/font/gofont/gomedium
Package gomedium provides the "Go Medium" TrueType font from the Go font family.
Package gomedium provides the "Go Medium" TrueType font from the Go font family.
image/font/gofont/gomediumitalic
Package gomediumitalic provides the "Go Medium Italic" TrueType font from the Go font family.
Package gomediumitalic provides the "Go Medium Italic" TrueType font from the Go font family.
image/font/gofont/gomono
Package gomono provides the "Go Mono" TrueType font from the Go font family.
Package gomono provides the "Go Mono" TrueType font from the Go font family.
image/font/gofont/gomonobold
Package gomonobold provides the "Go Mono Bold" TrueType font from the Go font family.
Package gomonobold provides the "Go Mono Bold" TrueType font from the Go font family.
image/font/gofont/gomonobolditalic
Package gomonobolditalic provides the "Go Mono Bold Italic" TrueType font from the Go font family.
Package gomonobolditalic provides the "Go Mono Bold Italic" TrueType font from the Go font family.
image/font/gofont/gomonoitalic
Package gomonoitalic provides the "Go Mono Italic" TrueType font from the Go font family.
Package gomonoitalic provides the "Go Mono Italic" TrueType font from the Go font family.
image/font/gofont/goregular
Package goregular provides the "Go Regular" TrueType font from the Go font family.
Package goregular provides the "Go Regular" TrueType font from the Go font family.
image/font/gofont/gosmallcaps
Package gosmallcaps provides the "Go Smallcaps" TrueType font from the Go font family.
Package gosmallcaps provides the "Go Smallcaps" TrueType font from the Go font family.
image/font/gofont/gosmallcapsitalic
Package gosmallcapsitalic provides the "Go Smallcaps Italic" TrueType font from the Go font family.
Package gosmallcapsitalic provides the "Go Smallcaps Italic" TrueType font from the Go font family.
image/font/inconsolata
Package inconsolata provides pre-rendered bitmap versions of the Inconsolata font family.
Package inconsolata provides pre-rendered bitmap versions of the Inconsolata font family.
image/font/opentype
Package opentype implements a glyph rasterizer for TTF (TrueType Fonts) and OTF (OpenType Fonts).
Package opentype implements a glyph rasterizer for TTF (TrueType Fonts) and OTF (OpenType Fonts).
image/font/plan9font
Package plan9font implements font faces for the Plan 9 font and subfont file formats.
Package plan9font implements font faces for the Plan 9 font and subfont file formats.
image/font/sfnt
Package sfnt implements a decoder for TTF (TrueType Fonts) and OTF (OpenType Fonts).
Package sfnt implements a decoder for TTF (TrueType Fonts) and OTF (OpenType Fonts).
image/internal/safemath
Package safemath contains overflow-safe math functions.
Package safemath contains overflow-safe math functions.
image/math/f32
Package f32 implements float32 vector and matrix types.
Package f32 implements float32 vector and matrix types.
image/math/f64
Package f64 implements float64 vector and matrix types.
Package f64 implements float64 vector and matrix types.
image/math/fixed
Package fixed implements fixed-point integer types.
Package fixed implements fixed-point integer types.
image/riff
Package riff implements the Resource Interchange File Format, used by media formats such as AVI, WAVE and WEBP.
Package riff implements the Resource Interchange File Format, used by media formats such as AVI, WAVE and WEBP.
image/tiff
Package tiff implements a TIFF image decoder and encoder.
Package tiff implements a TIFF image decoder and encoder.
image/tiff/lzw
Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
Package lzw implements the Lempel-Ziv-Welch compressed data format, described in T. A. Welch, “A Technique for High-Performance Data Compression”, Computer, 17(6) (June 1984), pp 8-19.
image/vector
Package vector provides a rasterizer for 2-D vector graphics.
Package vector provides a rasterizer for 2-D vector graphics.
image/vp8
Package vp8 implements a decoder for the VP8 lossy image format.
Package vp8 implements a decoder for the VP8 lossy image format.
image/vp8l
Package vp8l implements a decoder for the VP8L lossless image format.
Package vp8l implements a decoder for the VP8L lossless image format.
image/webp
Package webp implements a decoder for WEBP images.
Package webp implements a decoder for WEBP images.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL