BioLib  4.3.0
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.Filters Class Reference

Static Public Member Functions

static Filt GetFilter (string name)
 
static Filt GetFilter (int type, int index)
 
static BioImage Base (string id, string name, bool inPlace)
 
static BioImage Base2 (string id, string id2, string name, bool inPlace)
 
static BioImage InPlace (string id, string name, bool inPlace)
 
static BioImage InPlace2 (string id, string id2, string name, bool inPlace)
 
static BioImage InPlacePartial (string id, string name, bool inPlace)
 
static BioImage Resize (string id, string name, bool inPlace, int w, int h)
 
static BioImage Rotate (string id, string name, bool inPlace, float angle, int a, int r, int g, int b)
 
static BioImage Transformation (string id, string name, bool inPlace, float angle)
 
static BioImage Copy (string id, string name, bool inPlace)
 
static BioImage Crop (string id, double x, double y, double w, double h)
 
static BioImage Crop (string id, RectangleD r)
 
static void Init ()
 It creates a dictionary of filters and their names.
 

Static Public Attributes

static int[,] indexs
 
static List< Filt > filters = new List<Filt>()
 

Member Function Documentation

◆ Base()

static BioImage BioLib.Filters.Base ( string id,
string name,
bool inPlace )
static

It takes an image, applies a filter to it, and returns the filtered image

Parameters
idThe id of the image to apply the filter to.
nameThe name of the filter.
inPlaceIf true, the image will be modified in place. If false, a new image will be created.
Returns
The image that was filtered.
436 {
437 BioImage img = Images.GetImage(id);
438 if (!inPlace)
439 img = BioImage.Copy(img);
440 try
441 {
442 Filt f = GetFilter(name);
443 BaseFilter fi = (BaseFilter)f.filt;
444 for (int i = 0; i < img.Buffers.Count; i++)
445 {
446 Bitmap bm = fi.Apply(img.Buffers[i]);
447 img.Buffers[i] = bm;
448 }
449 if (!inPlace)
450 {
451 Images.AddImage(img);
452 }
453 }
454 catch (Exception e)
455 {
456 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
457 dialog.Show();
458 }
459 return img;
460 }
AForge.Bitmap Bitmap
Definition Bio.cs:53
static Bitmap bm
Definition Bio.cs:8524
Definition Bio.cs:1872
static BioImage Copy(BioImage b, bool rois)
Definition Bio.cs:2133
List< AForge.Bitmap > Buffers
Definition Bio.cs:1980
Definition Bio.cs:374
IFilter filt
Definition Bio.cs:389
static Filt GetFilter(string name)
Definition Bio.cs:406
Definition Bio.cs:68
static void AddImage(BioImage im)
Definition Bio.cs:86
static BioImage GetImage(string ids)
Definition Bio.cs:73

◆ Base2()

static BioImage BioLib.Filters.Base2 ( string id,
string id2,
string name,
bool inPlace )
static

It takes two images, applies a filter to the first image, and then applies the second image to the first image

Parameters
idthe image id
id2The image to be filtered
nameThe name of the filter.
inPlaceIf true, the image will be modified in place. If false, a new image will be created.
Returns
The image that was filtered.
472 {
473 BioImage c2 = Images.GetImage(id);
474 BioImage img = Images.GetImage(id2);
475 if (!inPlace)
476 img = BioImage.Copy(img);
477 try
478 {
479 Filt f = GetFilter(name);
480 BaseFilter2 fi = (BaseFilter2)f.filt;
481 for (int i = 0; i < img.Buffers.Count; i++)
482 {
483 fi.OverlayImage = c2.Buffers[i];
484 img.Buffers[i] = fi.Apply(img.Buffers[i]);
485 }
486 if (!inPlace)
487 {
488 Images.AddImage(img);
489 }
490 return img;
491 }
492 catch (Exception e)
493 {
494 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
495 dialog.Show();
496 }
497 return img;
498 }

◆ Copy()

static BioImage BioLib.Filters.Copy ( string id,
string name,
bool inPlace )
static

It takes an image, applies a filter to it, and returns the filtered image

Parameters
idthe id of the image to be filtered
nameThe name of the filter to apply
inPlaceIf true, the image will be modified in place. If false, a copy of the image will be created and the copy will be modified.
Returns
The image that was copied.
724 {
725 BioImage img = Images.GetImage(id);
726 if (!inPlace)
727 img = BioImage.Copy(img);
728 try
729 {
730 Filt f = GetFilter(name);
731 BaseUsingCopyPartialFilter fi = (BaseUsingCopyPartialFilter)f.filt;
732 for (int i = 0; i < img.Buffers.Count; i++)
733 {
734 img.Buffers[i] = fi.Apply((Bitmap)img.Buffers[i]);
735 }
736 if (!inPlace)
737 {
738 Images.AddImage(img);
739 }
740 }
741 catch (Exception e)
742 {
743 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
744 dialog.Show();
745 }
746 return img;
747 }

◆ Crop() [1/2]

static BioImage BioLib.Filters.Crop ( string id,
double x,
double y,
double w,
double h )
static

It takes an image, crops it, and returns the cropped image

Parameters
idthe id of the image to crop
xx coordinate of the top left corner of the rectangle
yy-coordinate of the top-left corner of the rectangle
wwidth
hheight
Returns
The cropped image.
758 {
759 BioImage c = Images.GetImage(id);
760 RectangleF r = c.ToImageSpace(new RectangleD(x, y, w, h));
761 Rectangle rec = new Rectangle((int)r.X, (int)r.Y, (int)Math.Abs(r.Width), (int)Math.Abs(r.Height));
762 BioImage img = BioImage.Copy(c, false);
763 for (int i = 0; i < img.Buffers.Count; i++)
764 {
765 img.Buffers[i].Crop(rec);
766 }
767 BioImage.AutoThreshold(img, true);
768 if (img.bitsPerPixel > 8)
769 img.StackThreshold(true);
770 else
771 img.StackThreshold(false);
772 return img;
773 }
AForge.Rectangle Rectangle
Definition Bio.cs:61
AForge.RectangleD RectangleD
Definition Fiji.cs:27
int bitsPerPixel
Definition Bio.cs:2065
PointD ToImageSpace(PointD p)
Convert a point in the stage coordinate system to a point in the image coordinate system.
Definition Bio.cs:3624

◆ Crop() [2/2]

static BioImage BioLib.Filters.Crop ( string id,
RectangleD r )
static

This function takes a string and a rectangle and returns a BioImage

Parameters
idthe id of the image to crop
RectangleD
Returns
A BioImage object.
781 {
782 return Crop(id, r.X, r.Y, r.W, r.H);
783 }
static BioImage Crop(string id, double x, double y, double w, double h)
Definition Bio.cs:757

◆ GetFilter() [1/2]

static Filt BioLib.Filters.GetFilter ( int type,
int index )
static

It returns a filter from the filters dictionary, using the indexs array to find the index of the filter in the dictionary

Parameters
typeThe type of filter you want to get.
indexThe index of the filter in the list of filters.
Returns
The value of the filter at the index of the type and index.
423 {
424 return filters[indexs[type, index]];
425 }
static List< Filt > filters
Definition Bio.cs:426
static int[,] indexs
Definition Bio.cs:400

◆ GetFilter() [2/2]

static Filt BioLib.Filters.GetFilter ( string name)
static

It takes a string as an argument and returns a filter object

Parameters
nameThe name of the filter.
Returns
The value of the key "name" in the dictionary "filters"
407 {
408 foreach (Filt item in filters)
409 {
410 if (item.name == name)
411 return item;
412 }
413 return null;
414 }
string name
Definition Bio.cs:388

◆ Init()

static void BioLib.Filters.Init ( )
static

It creates a dictionary of filters and their names.

787 {
788 //Base Filters
789 indexs = new int[9, 32];
790 indexs[0, 0] = filters.Count;
791 Filt f = new Filt("AdaptiveSmoothing", new AdaptiveSmoothing(), Filt.Type.Base);
792 filters.Add(f);
793 indexs[0, 1] = filters.Count;
794 f = new Filt("BayerFilter", new BayerFilter(), Filt.Type.Base);
795 filters.Add(f);
796 indexs[0, 2] = filters.Count;
797 f = new Filt("BayerFilterOptimized", new BayerFilterOptimized(), Filt.Type.Base);
798 filters.Add(f);
799 indexs[0, 3] = filters.Count;
800 f = new Filt("BayerDithering", new BayerDithering(), Filt.Type.Base);
801 filters.Add(f);
802 indexs[0, 4] = filters.Count;
803 f = new Filt("ConnectedComponentsLabeling", new ConnectedComponentsLabeling(), Filt.Type.Base);
804 filters.Add(f);
805 indexs[0, 5] = filters.Count;
806 f = new Filt("ExtractChannel", new ExtractChannel(), Filt.Type.Base);
807 filters.Add(f);
808 indexs[0, 6] = filters.Count;
809 f = new Filt("ExtractNormalizedRGBChannel", new ExtractNormalizedRGBChannel(), Filt.Type.Base);
810 filters.Add(f);
811 indexs[0, 7] = filters.Count;
812 f = new Filt("Grayscale", new Grayscale(0.2125, 0.7154, 0.0721), Filt.Type.Base);
813 filters.Add(f);
814 //f = new Filt("TexturedFilter", new TexturedFilter());
815 //filters.Add(f);
816 indexs[0, 8] = filters.Count;
817 f = new Filt("WaterWave", new WaterWave(), Filt.Type.Base);
818 filters.Add(f);
819 indexs[0, 9] = filters.Count;
820 f = new Filt("YCbCrExtractChannel", new YCbCrExtractChannel(), Filt.Type.Base);
821 filters.Add(f);
822 indexs[0, 10] = filters.Count;
823 //BaseFilter2
824
825 f = new Filt("ThresholdedDifference", new ThresholdedDifference(), Filt.Type.Base2);
826 filters.Add(f);
827 indexs[1, 0] = filters.Count;
828 f = new Filt("ThresholdedEuclideanDifference", new ThresholdedEuclideanDifference(), Filt.Type.Base2);
829 filters.Add(f);
830 indexs[1, 1] = filters.Count;
831
832 //BaseInPlaceFilter
833 indexs[2, 0] = filters.Count;
834 f = new Filt("BackwardQuadrilateralTransformation", new BackwardQuadrilateralTransformation(), Filt.Type.InPlace);
835 filters.Add(f);
836 indexs[2, 1] = filters.Count;
837 f = new Filt("BlobsFiltering", new BlobsFiltering(), Filt.Type.InPlace);
838 filters.Add(f);
839 indexs[2, 2] = filters.Count;
840 f = new Filt("BottomHat", new BottomHat(), Filt.Type.InPlace);
841 filters.Add(f);
842 indexs[2, 3] = filters.Count;
843 f = new Filt("BradleyLocalThresholding", new BradleyLocalThresholding(), Filt.Type.InPlace);
844 filters.Add(f);
845 indexs[2, 4] = filters.Count;
846 f = new Filt("CanvasCrop", new CanvasCrop(new Rectangle(0, 0, 0, 0)), Filt.Type.InPlace);
847 filters.Add(f);
848 indexs[2, 5] = filters.Count;
849 f = new Filt("CanvasFill", new CanvasFill(new Rectangle(0, 0, 0, 0)), Filt.Type.InPlace);
850 filters.Add(f);
851 indexs[2, 6] = filters.Count;
852 f = new Filt("CanvasMove", new CanvasMove(new IntPoint()), Filt.Type.InPlace);
853 filters.Add(f);
854 indexs[2, 7] = filters.Count;
855 f = new Filt("FillHoles", new FillHoles(), Filt.Type.InPlace);
856 filters.Add(f);
857 indexs[2, 8] = filters.Count;
858 f = new Filt("FlatFieldCorrection", new FlatFieldCorrection(), Filt.Type.InPlace);
859 filters.Add(f);
860 indexs[2, 9] = filters.Count;
861 f = new Filt("TopHat", new TopHat(), Filt.Type.InPlace);
862 filters.Add(f);
863
864 //BaseInPlaceFilter2
865 indexs[3, 0] = filters.Count;
866 f = new Filt("Add", new Add(), Filt.Type.InPlace2);
867 filters.Add(f);
868 indexs[3, 1] = filters.Count;
869 f = new Filt("Difference", new Difference(), Filt.Type.InPlace2);
870 filters.Add(f);
871 indexs[3, 2] = filters.Count;
872 f = new Filt("Intersect", new Intersect(), Filt.Type.InPlace2);
873 filters.Add(f);
874 indexs[3, 3] = filters.Count;
875 f = new Filt("Merge", new Merge(), Filt.Type.InPlace2);
876 filters.Add(f);
877 indexs[3, 4] = filters.Count;
878 f = new Filt("Morph", new Morph(), Filt.Type.InPlace2);
879 filters.Add(f);
880 indexs[3, 5] = filters.Count;
881 f = new Filt("MoveTowards", new MoveTowards(), Filt.Type.InPlace2);
882 filters.Add(f);
883 indexs[3, 6] = filters.Count;
884 f = new Filt("StereoAnaglyph", new StereoAnaglyph(), Filt.Type.InPlace2);
885 filters.Add(f);
886 indexs[3, 7] = filters.Count;
887 f = new Filt("Subtract", new Subtract(), Filt.Type.InPlace2);
888 filters.Add(f);
889 //f = new Filt("Add", new TexturedMerge(), Filt.Type.InPlace2);
890 //filters.Add(f);
891
892 //BaseInPlacePartialFilter
893 indexs[4, 0] = filters.Count;
894 f = new Filt("AdditiveNoise", new AdditiveNoise(), Filt.Type.InPlacePartial);
895 filters.Add(f);
896 //f = new Filt("ApplyMask", new ApplyMask(), Filt.Type.InPlacePartial2);
897 //filters.Add(f);
898 indexs[4, 1] = filters.Count;
899 f = new Filt("BrightnessCorrection", new BrightnessCorrection(), Filt.Type.InPlacePartial);
900 filters.Add(f);
901 indexs[4, 2] = filters.Count;
902 f = new Filt("ChannelFiltering", new ChannelFiltering(), Filt.Type.InPlacePartial);
903 filters.Add(f);
904 indexs[4, 3] = filters.Count;
905 f = new Filt("ColorFiltering", new ColorFiltering(), Filt.Type.InPlacePartial);
906 filters.Add(f);
907 indexs[4, 4] = filters.Count;
908 f = new Filt("ColorRemapping", new ColorRemapping(), Filt.Type.InPlacePartial);
909 filters.Add(f);
910 indexs[4, 5] = filters.Count;
911 f = new Filt("ContrastCorrection", new ContrastCorrection(), Filt.Type.InPlacePartial);
912 filters.Add(f);
913 indexs[4, 6] = filters.Count;
914 f = new Filt("ContrastStretch", new ContrastStretch(), Filt.Type.InPlacePartial);
915 filters.Add(f);
916
917 //f = new Filt("ErrorDiffusionDithering", new ErrorDiffusionDithering(), Filt.Type.InPlacePartial);
918 //filters.Add(f);
919 indexs[4, 7] = filters.Count;
920 f = new Filt("EuclideanColorFiltering", new EuclideanColorFiltering(), Filt.Type.InPlacePartial);
921 filters.Add(f);
922 indexs[4, 8] = filters.Count;
923 f = new Filt("GammaCorrection", new GammaCorrection(), Filt.Type.InPlacePartial);
924 filters.Add(f);
925 indexs[4, 9] = filters.Count;
926 f = new Filt("HistogramEqualization", new HistogramEqualization(), Filt.Type.InPlacePartial);
927 filters.Add(f);
928 indexs[4, 10] = filters.Count;
929 f = new Filt("HorizontalRunLengthSmoothing", new HorizontalRunLengthSmoothing(), Filt.Type.InPlacePartial);
930 filters.Add(f);
931 indexs[4, 11] = filters.Count;
932 f = new Filt("HSLFiltering", new HSLFiltering(), Filt.Type.InPlacePartial);
933 filters.Add(f);
934 indexs[4, 12] = filters.Count;
935 f = new Filt("HueModifier", new HueModifier(), Filt.Type.InPlacePartial);
936 filters.Add(f);
937 indexs[4, 13] = filters.Count;
938 f = new Filt("Invert", new Invert(), Filt.Type.InPlacePartial);
939 filters.Add(f);
940 indexs[4, 14] = filters.Count;
941 f = new Filt("LevelsLinear", new LevelsLinear(), Filt.Type.InPlacePartial);
942 filters.Add(f);
943 indexs[4, 15] = filters.Count;
944 f = new Filt("LevelsLinear16bpp", new LevelsLinear16bpp(), Filt.Type.InPlacePartial);
945 filters.Add(f);
946 //indexs[4, 16] = 46;
947 //f = new Filt("MaskedFilter", new MaskedFilter(), Filt.Type.InPlacePartial);
948 //filters.Add(f);
949 //f = new Filt("Mirror", new Mirror(), Filt.Type.InPlacePartial);
950 //filters.Add(f);
951 indexs[4, 16] = filters.Count;
952 f = new Filt("OrderedDithering", new OrderedDithering(), Filt.Type.InPlacePartial);
953 filters.Add(f);
954 indexs[4, 17] = filters.Count;
955 f = new Filt("OtsuThreshold", new OtsuThreshold(), Filt.Type.InPlacePartial);
956 filters.Add(f);
957 indexs[4, 19] = filters.Count;
958 f = new Filt("Pixellate", new Pixellate(), Filt.Type.InPlacePartial);
959 filters.Add(f);
960 indexs[4, 20] = filters.Count;
961 f = new Filt("PointedColorFloodFill", new PointedColorFloodFill(), Filt.Type.InPlacePartial);
962 filters.Add(f);
963 indexs[4, 21] = filters.Count;
964 f = new Filt("PointedMeanFloodFill", new PointedMeanFloodFill(), Filt.Type.InPlacePartial);
965 filters.Add(f);
966 indexs[4, 22] = filters.Count;
967 f = new Filt("ReplaceChannel", new Invert(), Filt.Type.InPlacePartial);
968 filters.Add(f);
969 indexs[4, 23] = filters.Count;
970 f = new Filt("RotateChannels", new LevelsLinear(), Filt.Type.InPlacePartial);
971 filters.Add(f);
972 indexs[4, 24] = filters.Count;
973 f = new Filt("SaltAndPepperNoise", new LevelsLinear16bpp(), Filt.Type.InPlacePartial);
974 filters.Add(f);
975 indexs[4, 25] = filters.Count;
976 f = new Filt("SaturationCorrection", new SaturationCorrection(), Filt.Type.InPlacePartial);
977 filters.Add(f);
978 indexs[4, 26] = filters.Count;
979 f = new Filt("Sepia", new Sepia(), Filt.Type.InPlacePartial);
980 filters.Add(f);
981 indexs[4, 26] = filters.Count;
982 f = new Filt("SimplePosterization", new SimplePosterization(), Filt.Type.InPlacePartial);
983 filters.Add(f);
984 indexs[4, 27] = filters.Count;
985 f = new Filt("SISThreshold", new SISThreshold(), Filt.Type.InPlacePartial);
986 filters.Add(f);
987 //f = new Filt("Texturer", new Texturer(), Filt.Type.InPlacePartial);
988 //filters.Add(f);
989 //f = new Filt("Threshold", new Threshold(), Filt.Type.InPlacePartial);
990 //filters.Add(f);
991 indexs[4, 28] = filters.Count;
992 f = new Filt("ThresholdWithCarry", new ThresholdWithCarry(), Filt.Type.InPlacePartial);
993 filters.Add(f);
994 indexs[4, 29] = filters.Count;
995 f = new Filt("VerticalRunLengthSmoothing", new VerticalRunLengthSmoothing(), Filt.Type.InPlacePartial);
996 filters.Add(f);
997 indexs[4, 30] = filters.Count;
998 f = new Filt("YCbCrFiltering", new YCbCrFiltering(), Filt.Type.InPlacePartial);
999 filters.Add(f);
1000 indexs[4, 31] = filters.Count;
1001 f = new Filt("YCbCrLinear", new YCbCrLinear(), Filt.Type.InPlacePartial);
1002 filters.Add(f);
1003 //f = new Filt("YCbCrReplaceChannel", new YCbCrReplaceChannel(), Filt.Type.InPlacePartial);
1004 //filters.Add(f);
1005
1006 //BaseResizeFilter
1007 indexs[5, 0] = filters.Count;
1008 f = new Filt("ResizeBicubic", new ResizeBicubic(0, 0), Filt.Type.Resize);
1009 filters.Add(f);
1010 indexs[5, 1] = filters.Count;
1011 f = new Filt("ResizeBilinear", new ResizeBilinear(0, 0), Filt.Type.Resize);
1012 filters.Add(f);
1013 indexs[5, 2] = filters.Count;
1014 f = new Filt("ResizeNearestNeighbor", new ResizeNearestNeighbor(0, 0), Filt.Type.Resize);
1015 filters.Add(f);
1016
1017 //BaseRotateFilter
1018 indexs[6, 0] = filters.Count;
1019 f = new Filt("RotateBicubic", new RotateBicubic(0), Filt.Type.Rotate);
1020 filters.Add(f);
1021 indexs[6, 1] = filters.Count;
1022 f = new Filt("RotateBilinear", new RotateBilinear(0), Filt.Type.Rotate);
1023 filters.Add(f);
1024 indexs[6, 2] = filters.Count;
1025 f = new Filt("RotateNearestNeighbor", new RotateNearestNeighbor(0), Filt.Type.Rotate);
1026 filters.Add(f);
1027
1028 //Transformation
1029 indexs[7, 0] = filters.Count;
1030 f = new Filt("Crop", new Crop(new Rectangle(0, 0, 0, 0)), Filt.Type.Transformation);
1031 filters.Add(f);
1032 indexs[7, 1] = filters.Count;
1033 f = new Filt("QuadrilateralTransformation", new QuadrilateralTransformation(), Filt.Type.Transformation);
1034 filters.Add(f);
1035 //f = new Filt("QuadrilateralTransformationBilinear", new QuadrilateralTransformationBilinear(), Filt.Type.Transformation);
1036 //filters.Add(f);
1037 //f = new Filt("QuadrilateralTransformationNearestNeighbor", new QuadrilateralTransformationNearestNeighbor(), Filt.Type.Transformation);
1038 //filters.Add(f);
1039 indexs[7, 2] = filters.Count;
1040 f = new Filt("Shrink", new Shrink(), Filt.Type.Transformation);
1041 filters.Add(f);
1042 indexs[7, 3] = filters.Count;
1043 f = new Filt("SimpleQuadrilateralTransformation", new SimpleQuadrilateralTransformation(), Filt.Type.Transformation);
1044 filters.Add(f);
1045 indexs[7, 4] = filters.Count;
1046 f = new Filt("TransformFromPolar", new TransformFromPolar(), Filt.Type.Transformation);
1047 filters.Add(f);
1048 indexs[7, 5] = filters.Count;
1049 f = new Filt("TransformToPolar", new TransformToPolar(), Filt.Type.Transformation);
1050 filters.Add(f);
1051
1052 //BaseUsingCopyPartialFilter
1053 indexs[8, 0] = filters.Count;
1054 f = new Filt("BinaryDilatation3x3", new BinaryDilatation3x3(), Filt.Type.Copy);
1055 filters.Add(f);
1056 indexs[8, 1] = filters.Count;
1057 f = new Filt("BilateralSmoothing ", new BilateralSmoothing(), Filt.Type.Copy);
1058 filters.Add(f);
1059 indexs[8, 2] = filters.Count;
1060 f = new Filt("BinaryErosion3x3 ", new BinaryErosion3x3(), Filt.Type.Copy);
1061 filters.Add(f);
1062
1063 }
Type
Definition Bio.cs:377

◆ InPlace()

static BioImage BioLib.Filters.InPlace ( string id,
string name,
bool inPlace )
static

It takes an image, applies a filter to it, and returns the image

Parameters
idThe id of the image to apply the filter to.
nameThe name of the filter
inPlaceIf true, the image will be modified in place. If false, a copy of the image will be created and modified.
Returns
The image that was passed in.
508 {
509 BioImage img = Images.GetImage(id);
510 if (!inPlace)
511 img = BioImage.Copy(img);
512 try
513 {
514 Filt f = GetFilter(name);
515 BaseInPlaceFilter fi = (BaseInPlaceFilter)f.filt;
516 for (int i = 0; i < img.Buffers.Count; i++)
517 {
518 img.Buffers[i] = fi.Apply((Bitmap)img.Buffers[i]);
519 }
520 if (!inPlace)
521 {
522 Images.AddImage(img);
523 }
524 return img;
525 }
526 catch (Exception e)
527 {
528 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
529 dialog.Show();
530 }
531 return img;
532 }

◆ InPlace2()

static BioImage BioLib.Filters.InPlace2 ( string id,
string id2,
string name,
bool inPlace )
static

This function takes an image, applies a filter to it, and returns the filtered image

Parameters
idthe image id
id2the image to be filtered
nameThe name of the filter
inPlacetrue or false
Returns
The image that was passed in.
542 {
543 BioImage c2 = Images.GetImage(id);
544 BioImage img = Images.GetImage(id2);
545 if (!inPlace)
546 img = BioImage.Copy(img);
547 try
548 {
549 Filt f = GetFilter(name);
550 BaseInPlaceFilter2 fi = (BaseInPlaceFilter2)f.filt;
551 for (int i = 0; i < img.Buffers.Count; i++)
552 {
553 fi.OverlayImage = c2.Buffers[i];
554 img.Buffers[i] = fi.Apply(img.Buffers[i]);
555 }
556 if (!inPlace)
557 {
558 Images.AddImage(img);
559 }
560 return img;
561 }
562 catch (Exception e)
563 {
564 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
565 dialog.Show();
566 }
567 return img;
568 }

◆ InPlacePartial()

static BioImage BioLib.Filters.InPlacePartial ( string id,
string name,
bool inPlace )
static

It takes an image, applies a filter to it, and returns the filtered image

Parameters
idthe id of the image to be filtered
nameThe name of the filter
inPlaceIf true, the image is modified in place. If false, a copy of the image is created and modified.
Returns
The image that was passed in.
578 {
579 BioImage img = Images.GetImage(id);
580 if (!inPlace)
581 img = BioImage.Copy(img);
582 try
583 {
584 Filt f = GetFilter(name);
585 BaseInPlacePartialFilter fi = (BaseInPlacePartialFilter)f.filt;
586 for (int i = 0; i < img.Buffers.Count; i++)
587 {
588 img.Buffers[i] = fi.Apply(img.Buffers[i]);
589 }
590 if (!inPlace)
591 {
592 Images.AddImage(img);
593 }
594 return img;
595 }
596 catch (Exception e)
597 {
598 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
599 dialog.Show();
600 }
601 return img;
602 }

◆ Resize()

static BioImage BioLib.Filters.Resize ( string id,
string name,
bool inPlace,
int w,
int h )
static

This function takes an image, resizes it, and returns the resized image

Parameters
idthe id of the image to be resized
nameThe name of the filter to use.
inPlaceIf true, the image will be modified in place. If false, a new image will be created.
wwidth
hheight
Returns
The image that was resized.
614 {
615 BioImage img = Images.GetImage(id);
616 if (!inPlace)
617 img = BioImage.Copy(img);
618 try
619 {
620 Filt f = GetFilter(name);
621 BaseResizeFilter fi = (BaseResizeFilter)f.filt;
622 fi.NewHeight = h;
623 fi.NewWidth = w;
624 for (int i = 0; i < img.Buffers.Count; i++)
625 {
626 img.Buffers[i] = fi.Apply(img.Buffers[i]);
627 }
628 if (!inPlace)
629 {
630 Images.AddImage(img);
631 }
632 }
633 catch (Exception e)
634 {
635 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
636 dialog.Show();
637 }
638 return img;
639 }

◆ Rotate()

static BioImage BioLib.Filters.Rotate ( string id,
string name,
bool inPlace,
float angle,
int a,
int r,
int g,
int b )
static

It takes an image, rotates it, and returns the rotated image

Parameters
idthe id of the image to be rotated
nameThe name of the filter
inPlacewhether to apply the filter to the original image or to a copy of it
anglethe angle to rotate the image
aalpha
rred
gthe image to be rotated
bblue
Returns
The image that was rotated.
653 {
654 BioImage img = Images.GetImage(id);
655 if (!inPlace)
656 img = BioImage.Copy(Images.GetImage(id));
657 try
658 {
659 Filt f = GetFilter(name);
660 BaseRotateFilter fi = (BaseRotateFilter)f.filt;
661 fi.Angle = angle;
662 fi.FillColor = Color.FromArgb(a, r, g, b);
663 for (int i = 0; i < img.Buffers.Count; i++)
664 {
665 img.Buffers[i] = fi.Apply(img.Buffers[i]);
666 }
667 if (!inPlace)
668 {
669 Images.AddImage(img);
670 }
671 }
672 catch (Exception e)
673 {
674 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
675 dialog.Show();
676 }
677 return img;
678
679 }
AForge.Color Color
Definition Bio.cs:55
return b
Definition Bio.cs:7393

◆ Transformation()

static BioImage BioLib.Filters.Transformation ( string id,
string name,
bool inPlace,
float angle )
static

This function takes an image, applies a transformation filter to it, and returns the transformed image

Parameters
idthe id of the image to be transformed
nameThe name of the filter.
inPlaceIf true, the image will be modified in place. If false, a new image will be created.
anglethe angle of rotation
Returns
The image that was transformed.
691 {
692 BioImage img = Images.GetImage(id);
693 if (!inPlace)
694 img = BioImage.Copy(img);
695 try
696 {
697 Filt f = GetFilter(name);
698 BaseTransformationFilter fi = (BaseTransformationFilter)f.filt;
699 for (int i = 0; i < img.Buffers.Count; i++)
700 {
701 img.Buffers[i] = fi.Apply(img.Buffers[i]);
702 }
703 if (!inPlace)
704 {
705 Images.AddImage(img);
706 }
707 }
708 catch (Exception e)
709 {
710 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, e.Message);
711 dialog.Show();
712 }
713 return img;
714 }

Member Data Documentation

◆ filters

List<Filt> BioLib.Filters.filters = new List<Filt>()
static

◆ indexs

int [,] BioLib.Filters.indexs
static

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