BioGTK  5.1.1
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images.
Loading...
Searching...
No Matches
BioGTK.ROI.Mask Class Reference

Represents a Mask layer. More...

Inheritance diagram for BioGTK.ROI.Mask:

Public Member Functions

bool IsSelected (int x, int y)
 
float GetValue (int x, int y)
 
void SetValue (int x, int y, float val)
 
 Mask (float[] fts, int width, int height, double physX, double physY)
 
 Mask (byte[] bts, int width, int height, double physX, double physY)
 
Gdk.Pixbuf GetColored (AForge.Color col, bool forceUpdate=false)
 
byte[] GetBytes ()
 
void Dispose ()
 

Public Attributes

float min = 0
 

Properties

int Width [get, set]
 
int Height [get, set]
 
double PhysicalSizeX [get, set]
 
double PhysicalSizeY [get, set]
 
Gdk.Pixbuf Pixbuf [get]
 

Detailed Description

Represents a Mask layer.

Constructor & Destructor Documentation

◆ Mask() [1/2]

BioGTK.ROI.Mask.Mask ( float[]  fts,
int  width,
int  height,
double  physX,
double  physY 
)
inline
629 {
630 this.width = width;
631 this.height = height;
632 PhysicalSizeX = physX;
633 PhysicalSizeY = physY;
634 mask = fts;
635 }
double PhysicalSizeX
Definition Bio.cs:582
double PhysicalSizeY
Definition Bio.cs:583

◆ Mask() [2/2]

BioGTK.ROI.Mask.Mask ( byte[]  bts,
int  width,
int  height,
double  physX,
double  physY 
)
inline
637 {
638 this.width = width;
639 this.height = height;
640 PhysicalSizeX = physX;
641 PhysicalSizeY = physY;
642 mask = new float[bts.Length];
643 for (int y = 0; y < height; y++)
644 {
645 for (int x = 0; x < width; x++)
646 {
647 int ind = y * width + x;
648 mask[ind] = (float)BitConverter.ToSingle(bts, ind * 4);
649 }
650 }
651 }

Member Function Documentation

◆ Dispose()

void BioGTK.ROI.Mask.Dispose ( )
inline
735 {
736 if(pixbuf!=null)
737 pixbuf.Dispose();
738 if(colored!=null)
739 colored.Dispose();
740 mask = null;
741 }

◆ GetBytes()

byte[] BioGTK.ROI.Mask.GetBytes ( )
inline
718 {
719 byte[] pixelData = new byte[width * height * 4];
720 for (int y = 0; y < height; y++)
721 {
722 for (int x = 0; x < width; x++)
723 {
724 int ind = y * width + x;
725 byte[] bt = BitConverter.GetBytes(mask[ind]);
726 pixelData[4 * ind] = bt[0];
727 pixelData[4 * ind + 1] = bt[1];
728 pixelData[4 * ind + 2] = bt[2];
729 pixelData[4 * ind + 3] = bt[3];
730 }
731 }
732 return pixelData;
733 }

◆ GetColored()

Gdk.Pixbuf BioGTK.ROI.Mask.GetColored ( AForge::Color  col,
bool  forceUpdate = false 
)
inline
708 {
709 if (updateColored || forceUpdate)
710 {
711 UpdateColored(col);
712 return colored;
713 }
714 else
715 return colored;
716 }

◆ GetValue()

float BioGTK.ROI.Mask.GetValue ( int  x,
int  y 
)
inline
613 {
614 int ind = y * width + x;
615 if (ind > mask.Length)
616 throw new ArgumentException("Point " + x + "," + y + " is outside the mask.");
617 return mask[ind];
618 }

◆ IsSelected()

bool BioGTK.ROI.Mask.IsSelected ( int  x,
int  y 
)
inline
602 {
603 int ind = y * width + x;
604 if (ind > mask.Length)
605 throw new ArgumentException("Point " + x + "," + y + " is outside the mask.");
606 if (mask[ind]>min)
607 {
608 return true;
609 }
610 return false;
611 }
float min
Definition Bio.cs:576

◆ SetValue()

void BioGTK.ROI.Mask.SetValue ( int  x,
int  y,
float  val 
)
inline
620 {
621 int ind = y * width + x;
622 if (ind > mask.Length)
623 throw new ArgumentException("Point " + x + "," + y + " is outside the mask.");
624 mask[ind] = val;
625 updatePixbuf = true;
626 updateColored = true;
627 }

Member Data Documentation

◆ min

float BioGTK.ROI.Mask.min = 0

Property Documentation

◆ Height

int BioGTK.ROI.Mask.Height
getset
581{ get { return height; } set { height = value; } }

◆ PhysicalSizeX

double BioGTK.ROI.Mask.PhysicalSizeX
getset
582{ get; set; }

◆ PhysicalSizeY

double BioGTK.ROI.Mask.PhysicalSizeY
getset
583{ get; set; }

◆ Pixbuf

Gdk.Pixbuf BioGTK.ROI.Mask.Pixbuf
get
653 {
654 get
655 {
656 if (updatePixbuf)
657 {
658 if (pixbuf != null)
659 pixbuf.Dispose();
660 byte[] pixelData = new byte[width * height * 4];
661 for (int y = 0; y < height; y++)
662 {
663 for (int x = 0; x < width; x++)
664 {
665 int ind = y * width + x;
666 if (mask[ind] > 0)
667 {
668 pixelData[4 * ind] = (byte)(mask[ind] / 255);// Blue
669 pixelData[4 * ind + 1] = (byte)(mask[ind] / 255);// Green
670 pixelData[4 * ind + 2] = (byte)(mask[ind] / 255);// Red
671 pixelData[4 * ind + 3] = 125;// Alpha
672 }
673 else
674 pixelData[4 * ind + 3] = 0;
675 }
676 }
677 pixbuf = new Gdk.Pixbuf(pixelData, true, 8, width, height, width * 4);
678 updatePixbuf = false;
679 return pixbuf;
680 }
681 else
682 return pixbuf;
683 }
684 }

◆ Width

int BioGTK.ROI.Mask.Width
getset
580{ get { return width; } set { width = value; } }

The documentation for this class was generated from the following file: