BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.ROI.Mask Class Reference

Represents a Mask layer. More...

Inheritance diagram for BioImager.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)
 
Bitmap GetColored (System.Drawing.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]
 
Bitmap Bitmap [get]
 

Detailed Description

Represents a Mask layer.

Definition at line 541 of file Bio.cs.

Constructor & Destructor Documentation

◆ Mask() [1/2]

BioImager.ROI.Mask.Mask ( float[]  fts,
int  width,
int  height,
double  physX,
double  physY 
)

Definition at line 595 of file Bio.cs.

596 {
597 this.width = width;
598 this.height = height;
599 PhysicalSizeX = physX;
600 PhysicalSizeY = physY;
601 mask = fts;
602 }

◆ Mask() [2/2]

BioImager.ROI.Mask.Mask ( byte[]  bts,
int  width,
int  height,
double  physX,
double  physY 
)

Definition at line 603 of file Bio.cs.

604 {
605 this.width = width;
606 this.height = height;
607 PhysicalSizeX = physX;
608 PhysicalSizeY = physY;
609 mask = new float[bts.Length];
610 for (int y = 0; y < height; y++)
611 {
612 for (int x = 0; x < width; x++)
613 {
614 int ind = y * width + x;
615 mask[ind] = (float)BitConverter.ToSingle(bts, ind * 4);
616 }
617 }
618 }

Member Function Documentation

◆ Dispose()

void BioImager.ROI.Mask.Dispose ( )

Definition at line 701 of file Bio.cs.

702 {
703 if (pixbuf != null)
704 pixbuf.Dispose();
705 if (colored != null)
706 colored.Dispose();
707 mask = null;
708 }

◆ GetBytes()

byte[] BioImager.ROI.Mask.GetBytes ( )

Definition at line 684 of file Bio.cs.

685 {
686 byte[] pixelData = new byte[width * height * 4];
687 for (int y = 0; y < height; y++)
688 {
689 for (int x = 0; x < width; x++)
690 {
691 int ind = y * width + x;
692 byte[] bt = BitConverter.GetBytes(mask[ind]);
693 pixelData[4 * ind] = bt[0];
694 pixelData[4 * ind + 1] = bt[1];
695 pixelData[4 * ind + 2] = bt[2];
696 pixelData[4 * ind + 3] = bt[3];
697 }
698 }
699 return pixelData;
700 }

◆ GetColored()

Bitmap BioImager.ROI.Mask.GetColored ( System.Drawing.Color  col,
bool  forceUpdate = false 
)

Definition at line 674 of file Bio.cs.

675 {
676 if (updateColored || forceUpdate)
677 {
678 UpdateColored(col);
679 return colored;
680 }
681 else
682 return colored;
683 }

◆ GetValue()

float BioImager.ROI.Mask.GetValue ( int  x,
int  y 
)

Definition at line 579 of file Bio.cs.

580 {
581 int ind = y * width + x;
582 if (ind > mask.Length)
583 throw new ArgumentException("Point " + x + "," + y + " is outside the mask.");
584 return mask[ind];
585 }

◆ IsSelected()

bool BioImager.ROI.Mask.IsSelected ( int  x,
int  y 
)

Definition at line 568 of file Bio.cs.

569 {
570 int ind = y * width + x;
571 if (ind > mask.Length)
572 return false;
573 if (mask[ind] > min)
574 {
575 return true;
576 }
577 return false;
578 }

◆ SetValue()

void BioImager.ROI.Mask.SetValue ( int  x,
int  y,
float  val 
)

Definition at line 586 of file Bio.cs.

587 {
588 int ind = y * width + x;
589 if (ind > mask.Length)
590 throw new ArgumentException("Point " + x + "," + y + " is outside the mask.");
591 mask[ind] = val;
592 updatePixbuf = true;
593 updateColored = true;
594 }

Member Data Documentation

◆ min

float BioImager.ROI.Mask.min = 0

Definition at line 543 of file Bio.cs.

Property Documentation

◆ Bitmap

Bitmap BioImager.ROI.Mask.Bitmap
get

Definition at line 619 of file Bio.cs.

620 {
621 get
622 {
623 if (updatePixbuf)
624 {
625 if (pixbuf != null)
626 pixbuf.Dispose();
627 byte[] pixelData = new byte[width * height * 4];
628 for (int y = 0; y < height; y++)
629 {
630 for (int x = 0; x < width; x++)
631 {
632 int ind = y * width + x;
633 if (mask[ind] > 0)
634 {
635 pixelData[4 * ind] = (byte)(mask[ind] / 255);// Blue
636 pixelData[4 * ind + 1] = (byte)(mask[ind] / 255);// Green
637 pixelData[4 * ind + 2] = (byte)(mask[ind] / 255);// Red
638 pixelData[4 * ind + 3] = 125;// Alpha
639 }
640 else
641 pixelData[4 * ind + 3] = 0;
642 }
643 }
644 pixbuf = new Bitmap("", width, height, PixelFormat.Format32bppArgb, pixelData, new ZCT(), 0);
645 updatePixbuf = false;
646 return pixbuf;
647 }
648 else
649 return pixbuf;
650 }
651 }

◆ Height

int BioImager.ROI.Mask.Height
getset

Definition at line 548 of file Bio.cs.

548{ get { return height; } set { height = value; } }

◆ PhysicalSizeX

double BioImager.ROI.Mask.PhysicalSizeX
getset

Definition at line 549 of file Bio.cs.

549{ get; set; }

◆ PhysicalSizeY

double BioImager.ROI.Mask.PhysicalSizeY
getset

Definition at line 550 of file Bio.cs.

550{ get; set; }

◆ Width

int BioImager.ROI.Mask.Width
getset

Definition at line 547 of file Bio.cs.

547{ get { return width; } set { width = value; } }

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