├── ImageM ├── +imagem │ ├── +actions │ │ ├── +analyze │ │ │ ├── AnalyzeImageRegions.m │ │ │ ├── AverageValueByRegion.m │ │ │ ├── MeasureWithinSelection.m │ │ │ ├── PlotImageLineProfile.m │ │ │ ├── SetImageScale.m │ │ │ ├── ShowImageHistogram.m │ │ │ └── VectorImageJointHistogram.m │ │ ├── +edit │ │ │ ├── CropImageSelection.m │ │ │ ├── PrintImageDocList.m │ │ │ └── SaveSelection.m │ │ ├── +file │ │ │ ├── CloseFrame.m │ │ │ ├── CreateImage.m │ │ │ ├── Exit.m │ │ │ ├── ExportImageToWorkspace.m │ │ │ ├── ImportImageFromBinaryFile.m │ │ │ ├── ImportImageFromWorkspace.m │ │ │ ├── ImportImageSeries.m │ │ │ ├── OpenDemoImage.m │ │ │ ├── OpenImage.m │ │ │ └── SaveImage.m │ │ ├── +image │ │ │ ├── ClearImageOverlay.m │ │ │ ├── ClearSpatialCalibration.m │ │ │ ├── ConvertDataType.m │ │ │ ├── ConvertImage3DToVectorImage.m │ │ │ ├── ConvertRGBImageToGrayscale.m │ │ │ ├── ConvertScalarImageToRGB.m │ │ │ ├── ConvertVectorImageToImage3D.m │ │ │ ├── ConvertVectorImageToRGB.m │ │ │ ├── DuplicateImage.m │ │ │ ├── EditChannelNames.m │ │ │ ├── EditSpatialCalibration.m │ │ │ ├── ExtractFrame.m │ │ │ ├── ExtractSlice.m │ │ │ ├── FlipImage.m │ │ │ ├── ImageConvertType.m │ │ │ ├── InvertImage.m │ │ │ ├── MergeImageChannels.m │ │ │ ├── PermuteDimensions.m │ │ │ ├── PrintImageInfo.m │ │ │ ├── RenameImage.m │ │ │ ├── ReorderChannels.m │ │ │ ├── ReshapeImage.m │ │ │ ├── RotateImage90.m │ │ │ ├── SetBrushSize.m │ │ │ ├── SetBrushValue.m │ │ │ ├── SetChannelDisplayType.m │ │ │ ├── SetDefaultConnectivity.m │ │ │ ├── SplitImageChannels.m │ │ │ ├── SplitImageRGB.m │ │ │ ├── UnfoldVectorImage.m │ │ │ └── UnfoldVectorImageWithMask.m │ │ ├── +process │ │ │ ├── +binary │ │ │ │ ├── BinaryImageOverlay.m │ │ │ │ ├── ConnectedComponentsLabeling.m │ │ │ │ ├── GeodesicDistanceMap.m │ │ │ │ ├── ImageAreaOpening.m │ │ │ │ ├── ImageBooleanOp.m │ │ │ │ ├── ImageSkeleton.m │ │ │ │ └── KeepLargestRegion.m │ │ │ ├── AdjustImageDynamic.m │ │ │ ├── ApplyImageFunction.m │ │ │ ├── CreateLabelValuesMap.m │ │ │ ├── FillImageHoles.m │ │ │ ├── ImageArithmetic.m │ │ │ ├── ImageAutoThresholdOtsu.m │ │ │ ├── ImageBoxMeanFilter.m │ │ │ ├── ImageClosing.m │ │ │ ├── ImageDilation.m │ │ │ ├── ImageErosion.m │ │ │ ├── ImageExtendedMaxima.m │ │ │ ├── ImageExtendedMinWatershed.m │ │ │ ├── ImageExtendedMinima.m │ │ │ ├── ImageGaussianFilter.m │ │ │ ├── ImageGradient.m │ │ │ ├── ImageGradientVector.m │ │ │ ├── ImageImposeMinima.m │ │ │ ├── ImageKMeansSegmentation.m │ │ │ ├── ImageLabelToRgb.m │ │ │ ├── ImageMathematic.m │ │ │ ├── ImageMaxEntropyThreshold.m │ │ │ ├── ImageMedianFilter.m │ │ │ ├── ImageMorphoGradient.m │ │ │ ├── ImageMorphologicalFilter.m │ │ │ ├── ImageMorphologicalReconstruction.m │ │ │ ├── ImageOpening.m │ │ │ ├── ImageOrthogonalProjection.m │ │ │ ├── ImageRegionalMaxima.m │ │ │ ├── ImageRegionalMinima.m │ │ │ ├── ImageReplaceValue.m │ │ │ ├── ImageThreshold.m │ │ │ ├── ImageValuesTransform.m │ │ │ ├── ImageWatershed.m │ │ │ ├── KillImageBorders.m │ │ │ └── VectorImageNorm.m │ │ ├── +table │ │ │ ├── +edit │ │ │ │ ├── ChoosePreferredPlotTypes.m │ │ │ │ ├── Concatenate.m │ │ │ │ ├── FilterFromColumnValues.m │ │ │ │ ├── RenameTable.m │ │ │ │ ├── SelectTableColumns.m │ │ │ │ ├── SelectTableRows.m │ │ │ │ └── Transpose.m │ │ │ ├── +file │ │ │ │ └── SaveTable.m │ │ │ ├── +plot │ │ │ │ ├── BoxPlot.m │ │ │ │ ├── GroupBoxPlot.m │ │ │ │ ├── PairPlot.m │ │ │ │ ├── PlotColumnHistogram.m │ │ │ │ ├── PlotColumns.m │ │ │ │ ├── PlotCorrelationCircles.m │ │ │ │ ├── PlotRows.m │ │ │ │ ├── ScatterGroups.m │ │ │ │ ├── ScatterPlot.m │ │ │ │ └── ViolinPlot.m │ │ │ ├── +process │ │ │ │ ├── Nmf.m │ │ │ │ ├── Pca.m │ │ │ │ ├── PcaDialog.m │ │ │ │ └── TableKMeans.m │ │ │ ├── CrossTable.m │ │ │ ├── FoldTableToImage.m │ │ │ ├── OpenDemoTable.m │ │ │ └── OpenTable.m │ │ ├── +view │ │ │ ├── Image3DIsosurface.m │ │ │ ├── ImageSetDisplayRange.m │ │ │ ├── PlotLabelMapCurvesFromTable.m │ │ │ ├── PrintImageDocList.m │ │ │ ├── SetBackgroundColor.m │ │ │ ├── SetCurrentZoomLevel.m │ │ │ ├── SetImageColorMap.m │ │ │ ├── SetZoomMode.m │ │ │ ├── ShowImage3DOrthoSlices.m │ │ │ ├── ZoomBestFit.m │ │ │ ├── ZoomIn.m │ │ │ ├── ZoomOne.m │ │ │ └── ZoomOut.m │ │ ├── BinaryImageAction.m │ │ ├── CurrentDocAction.m │ │ ├── CurrentImageAction.m │ │ ├── CurrentTableAction.m │ │ ├── GenericAction.m │ │ ├── Image3DAction.m │ │ ├── LabelImageAction.m │ │ ├── PrintHello.m │ │ ├── ScalarImageAction.m │ │ ├── SelectTool.m │ │ ├── TimeLapseImageAction.m │ │ └── VectorImageAction.m │ ├── +app │ │ ├── ImageDoc.m │ │ ├── ImagemAppData.m │ │ ├── ImagemDoc.m │ │ └── TableDoc.m │ ├── +gui │ │ ├── +events │ │ │ ├── ImageDisplayListener.m │ │ │ └── MouseListener.m │ │ ├── +icons │ │ │ ├── lineSegment.png │ │ │ ├── points.png │ │ │ ├── polygon.png │ │ │ └── polyline.png │ │ ├── Action.m │ │ ├── FrameMenuBuilder.m │ │ ├── GenericDialog.m │ │ ├── GuiOptions.m │ │ ├── Image3DSliceViewer.m │ │ ├── Image5DSliceViewer.m │ │ ├── ImageUtils.m │ │ ├── ImageViewer.m │ │ ├── ImagemAction.m │ │ ├── ImagemFrame.m │ │ ├── ImagemGUI.m │ │ ├── ImagemTool.m │ │ ├── PlanarImageViewer.m │ │ ├── TableFrame.m │ │ └── Tool.m │ ├── +tools │ │ ├── Brush.m │ │ ├── FloodFillTool.m │ │ ├── InteractivePointMeasure.m │ │ ├── LineProfile.m │ │ ├── PickValueOrColor.m │ │ ├── PlotClickedLabelCurve.m │ │ ├── PlotImage3DZProfile.m │ │ ├── PlotVectorImageChannels.m │ │ ├── PrintCurrentPointPosition.m │ │ ├── ScrollImagePosition.m │ │ ├── SelectLineSegment.m │ │ ├── SelectPoints.m │ │ ├── SelectPolygon.m │ │ ├── SelectPolyline.m │ │ ├── SelectRectangle.m │ │ ├── SetPixelToWhite.m │ │ └── ShowCursorPosition.m │ └── +util │ │ ├── +color │ │ └── blue2White2Red.m │ │ ├── +enums │ │ ├── BasicColors.m │ │ ├── ColorMaps.m │ │ ├── Connectivities2D.m │ │ ├── Connectivities3D.m │ │ └── RelationalOperators.m │ │ └── +vectorImage │ │ ├── VectorImageMaxChannel.m │ │ ├── VectorImageNorm.m │ │ ├── VectorImageSingleChannel.m │ │ └── VectorImageView.m ├── ImageM.m └── go.m ├── LICENSE.txt ├── README.md ├── docs ├── _config.yml └── web │ ├── _config.yml │ └── index.md └── tests └── imagem ├── app └── test_ImagemApp.m └── util └── vectorImage ├── test_VectorImageMaxChannel.m ├── test_VectorImageNorm.m └── test_VectorImageSingleChannel.m /ImageM/+imagem/+actions/+analyze/ShowImageHistogram.m: -------------------------------------------------------------------------------- 1 | classdef ShowImageHistogram < imagem.actions.CurrentImageAction 2 | % Display histogram of current image. 3 | % 4 | % output = ShowImageHistogramAction(input) 5 | % 6 | % Example 7 | % ShowImageHistogramAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2011-11-11, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ShowImageHistogram() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | disp('Show image histogram'); 26 | 27 | img = currentImage(frame); 28 | 29 | % if selection exists, use it as roi 30 | roi = []; 31 | if isprop(frame, 'Selection') && ~isempty(frame.Selection) 32 | 33 | selection = frame.Selection; 34 | type = selection.Type; 35 | 36 | if strcmpi(type, 'Polygon') 37 | poly = selection.Data; 38 | roi = roipoly(img.Data(:,:,1,1,1), poly(:,2), poly(:,1)); 39 | elseif strcmp(type, 'box') 40 | box = selection.Data; 41 | poly = boxToPolygon(box); 42 | roi = roipoly(img.Data(:,:,1,1,1), poly(:,2), poly(:,1)); 43 | else 44 | warning('Can not use ROI with type %s forhistogram, compute whole histogram', type); 45 | end 46 | end 47 | 48 | % open figure to display histogram 49 | figure; 50 | histogram(img, frame.DisplayRange, roi); 51 | end 52 | end 53 | 54 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+edit/CropImageSelection.m: -------------------------------------------------------------------------------- 1 | classdef CropImageSelection < imagem.actions.CurrentImageAction 2 | % Crop current rectangular selection. 3 | % 4 | % Class CropImageSelectionAction 5 | % 6 | % Example 7 | % CropImageSelectionAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = CropImageSelection() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | selection = frame.Selection; 37 | if isempty(selection) 38 | warndlg('Requires a non empty selection', ... 39 | 'Empty Selection', 'modal'); 40 | return; 41 | end 42 | 43 | type = selection.Type; 44 | if ~ismember(lower(type), {'box'}) 45 | warndlg('Current selection must be a box', ... 46 | 'Invalid Selection', 'modal'); 47 | return; 48 | end 49 | 50 | box = selection.Data; 51 | box = round(box); 52 | 53 | img = currentImage(frame); 54 | nd = ndims(img); 55 | if nd > 2 56 | box = [box 1 size(img, 3)]; 57 | end 58 | cropped = crop(img, box); 59 | 60 | % add image to application, and create new display 61 | newDoc = addImageDocument(frame, cropped); 62 | 63 | tag = frame.Doc.Tag; 64 | newTag = newDoc.Tag; 65 | 66 | % history 67 | pattern = ['%s = crop(%s, [' repmat(' %d %d', 1, nd) ']);\n']; 68 | string = sprintf(pattern, newTag, tag, box); 69 | addToHistory(frame, string); 70 | 71 | end 72 | end % end methods 73 | 74 | end % end classdef 75 | 76 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+edit/PrintImageDocList.m: -------------------------------------------------------------------------------- 1 | classdef PrintImageDocList < imagem.gui.Action 2 | % Print the list of open documents. 3 | % 4 | % output = PrintImageDocListAction(input) 5 | % 6 | % Example 7 | % PrintImageDocListAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-07, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = PrintImageDocList() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % get handle to viewer figure, and current doc 27 | app = frame.Gui.App; 28 | docList = getDocuments(app); 29 | 30 | if ~isempty(docList) 31 | disp('Current list of images:'); 32 | for i = 1:length(docList) 33 | doc = docList{i}; 34 | if ~isempty(doc.Image) 35 | fprintf('(%s): %s\n', doc.Tag, doc.Image.Name); 36 | end 37 | end 38 | else 39 | disp('Current list of images: (empty)'); 40 | end 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+edit/SaveSelection.m: -------------------------------------------------------------------------------- 1 | classdef SaveSelection < imagem.actions.CurrentImageAction 2 | % Save current selection in text file. 3 | % 4 | % Class SaveSelectionAction 5 | % 6 | % Example 7 | % SaveSelectionAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-14, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SaveSelection() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | disp('Save current image selection'); 37 | 38 | selection = frame.Selection; 39 | if isempty(selection) 40 | errordlg('No selection in current image'); 41 | return; 42 | end 43 | 44 | % Open dialog to save selection 45 | [fileName, pathName] = uiputfile( ... 46 | {'*.txt', 'Text file (*.txt)'; ... 47 | '*.*', 'All Files (*.*)'}, ... 48 | 'Save Selection'); 49 | 50 | if isequal(fileName,0) || isequal(pathName,0) 51 | return; 52 | end 53 | 54 | % open file for writing 55 | f = fopen(fullfile(pathName, fileName), 'wt'); 56 | if f == -1 57 | errordlg(['Could not open file:\n' fullfile(pathName, fileName)]); 58 | return; 59 | end 60 | 61 | 62 | % different type of processing depending on selection type 63 | switch lower(selection.Type) 64 | case {'polyline', 'polygon', 'pointset'} 65 | % number of vertices 66 | nv = size(selection.Data, 1); 67 | 68 | % write selection type 69 | fprintf(f, '# %s 2 %d\n', selection.Type, nv); 70 | 71 | for i = 1:nv 72 | fprintf(f, '%d %d\n', selection.Data(i,1), selection.Data(i,2)); 73 | end 74 | 75 | otherwise 76 | errordlg('Can not save type-%s selections', selection.Type); 77 | return; 78 | end 79 | 80 | % closes the file 81 | fclose(f); 82 | 83 | end 84 | end % end methods 85 | 86 | end % end classdef 87 | 88 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/CloseFrame.m: -------------------------------------------------------------------------------- 1 | classdef CloseFrame < imagem.gui.Action 2 | % Close the current ImageM figure. 3 | % 4 | % output = CloseFrame(input) 5 | % 6 | % Example 7 | % CloseFrame 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = CloseFrame() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | % disp('Close image action'); 26 | 27 | % doc = frame.Doc; 28 | 29 | close(frame); 30 | 31 | % if isempty(getViews(doc)) 32 | % app = frame.Gui.App; 33 | % removeDocument(app, doc); 34 | % end 35 | end 36 | end 37 | 38 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/CreateImage.m: -------------------------------------------------------------------------------- 1 | classdef CreateImage < imagem.gui.Action 2 | % Open a dialog to create a new image. 3 | % 4 | % Class CreateImageAction 5 | % 6 | % Example 7 | % CreateImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = CreateImage() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | methods 33 | function run(obj, frame) %#ok 34 | disp('create a new image'); 35 | 36 | prompt = {'Size X:', 'Size Y:', 'Data type:', 'Fill with:'}; 37 | name = 'Create a new image'; 38 | numLines = 1; 39 | defaultAnswer = {'256', '256', 'uint8', '0'}; 40 | 41 | ok = false; 42 | while ~ok 43 | answer = inputdlg(prompt, name, numLines, defaultAnswer); 44 | if isempty(answer) 45 | return; 46 | end 47 | 48 | defaultAnswer = answer; 49 | 50 | dimX = str2double(answer{1}); 51 | if isnan(dimX) 52 | errordlg(['Could not interpret input for dim X: ' answer{1}]); 53 | end 54 | 55 | dimY = str2double(answer{2}); 56 | if isnan(dimY) 57 | errordlg(['Could not interpret input for dim Y: ' answer{2}]); 58 | end 59 | 60 | dataType = answer{3}; 61 | 62 | fillValue = str2double(answer{4}); 63 | if isnan(fillValue) 64 | errordlg(['Could not interpret input for fill Value: ' answer{4}]); 65 | end 66 | 67 | ok = true; 68 | end 69 | 70 | img = Image.create([dimX dimY], dataType); 71 | img(:) = fillValue; 72 | 73 | addImageDocument(frame, img); 74 | end 75 | 76 | end 77 | 78 | end % end classdef 79 | 80 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/Exit.m: -------------------------------------------------------------------------------- 1 | classdef Exit < imagem.gui.Action 2 | % Close the application. 3 | % 4 | % output = ExitAction(input) 5 | % 6 | % Example 7 | % ExitAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function run(obj, frame) %#ok 20 | disp('quit...'); 21 | exit(frame.Gui); 22 | end 23 | end 24 | 25 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/ExportImageToWorkspace.m: -------------------------------------------------------------------------------- 1 | classdef ExportImageToWorkspace < imagem.actions.CurrentImageAction 2 | % Export current image to workspace. 3 | % 4 | % Class ExportImageToWorkspace 5 | % 6 | % Example 7 | % ExportImageToWorkspace 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ExportImageToWorkspace() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('Export current image to workspace'); 36 | 37 | % open dialog to input image name 38 | prompt = {'Enter image name:'}; 39 | title = 'Export Image Data'; 40 | lines = 1; 41 | def = {'img'}; 42 | options = struct('Resize', 'on'); 43 | answer = inputdlg(prompt, title, lines, def, options); 44 | 45 | % if user cancels, answer is empty 46 | if isempty(answer) 47 | return; 48 | end 49 | 50 | assignin('base', answer{1}, currentImage(frame)); 51 | end 52 | end % end methods 53 | 54 | end % end classdef 55 | 56 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/ImportImageFromWorkspace.m: -------------------------------------------------------------------------------- 1 | classdef ImportImageFromWorkspace < imagem.gui.Action 2 | % Import an image from workspace. 3 | % 4 | % Class ImportImageFromWorkspaceAction 5 | % 6 | % Example 7 | % ImportImageFromWorkspace 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-07, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function this = ImportImageFromWorkspace() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('Import image from workspace'); 36 | 37 | % open dialog to input image name 38 | prompt = {'Enter Variable Name:'}; 39 | title = 'Import From Workspace'; 40 | lines = 1; 41 | def = {'ans'}; 42 | answer = inputdlg(prompt, title, lines, def); 43 | 44 | % if user cancels, answer is empty 45 | if isempty(answer) 46 | return; 47 | end 48 | 49 | data = evalin('base', answer{1}); 50 | 51 | if isa(data, 'Image') 52 | img = data; 53 | else 54 | img = Image(data); 55 | end 56 | 57 | % add image to application, and create new display 58 | addImageDocument(frame, img); 59 | end 60 | end % end methods 61 | 62 | end % end classdef 63 | 64 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/OpenDemoImage.m: -------------------------------------------------------------------------------- 1 | classdef OpenDemoImage < imagem.gui.Action 2 | % Open and display one of the demo images. 3 | % 4 | % Class OpenDemoImageAction 5 | % 6 | % Example 7 | % OpenDemoImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-07, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | ImageName; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = OpenDemoImage(imageName) 28 | % Constructor for OpenDemoImage class 29 | 30 | % initialize image name 31 | obj.ImageName = imageName; 32 | end 33 | 34 | end % end constructors 35 | 36 | 37 | %% Methods 38 | methods 39 | function run(obj, frame) %#ok 40 | 41 | % read the demo image 42 | img = Image.read(obj.ImageName); 43 | 44 | % add image to application, and create new display 45 | frame2 = createImageFrame(frame, img); 46 | 47 | tag = frame2.Doc.Tag; 48 | 49 | % history 50 | string = sprintf('%s = Image.read(''%s'');\n', tag, obj.ImageName); 51 | addToHistory(frame2, string); 52 | end 53 | end % end methods 54 | 55 | end % end classdef 56 | 57 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/OpenImage.m: -------------------------------------------------------------------------------- 1 | classdef OpenImage < imagem.gui.Action 2 | % Open an image from a file. 3 | % 4 | % Class OpenImageAction 5 | % 6 | % Example 7 | % OpenImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-07, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | 20 | %% Constructor 21 | methods 22 | function obj = OpenImage() 23 | % Constructor for OpenImageAction class 24 | end 25 | 26 | end % end constructors 27 | 28 | 29 | %% Methods 30 | methods 31 | function run(obj, viewer) %#ok 32 | disp('Open new Image '); 33 | 34 | [fileName, pathName] = uigetfile( ... 35 | {'*.gif;*.jpg;*.jpeg;*.bmp;*.png;*.tif;*.tiff;*.hdr;*.dcm;*.mhd;*.vgi', ... 36 | 'All Image Files (*.tif, *.bmp, *.png, *.hdr, *.dcm, *.mhd...)'; ... 37 | '*.tif;*.tiff', 'TIF Files (*.tif, *.tiff)'; ... 38 | '*.jpg', 'JPG Files (*.jpg)'; ... 39 | '*.bmp', 'BMP Files (*.bmp)'; ... 40 | '*.png', 'PNG Files (*.png)'; ... 41 | '*.hdr', 'Mayo Analyze Files (*.hdr)'; ... 42 | '*.dcm', 'DICOM Files (*.dcm)'; ... 43 | '*.mhd;*.mha', 'MetaImage data files (*.mha, *.mhd)'; ... 44 | '*.vgi', 'VGStudio Max files (*.vgi)'; ... 45 | '*.*', 'All Files (*.*)'}, ... 46 | 'Choose a stack or the first slice of a series:'); 47 | 48 | if isequal(fileName,0) || isequal(pathName,0) 49 | return; 50 | end 51 | 52 | % read the selected file 53 | imagePath = fullfile(pathName, fileName); 54 | img = Image.read(imagePath); 55 | 56 | % add image to application, and create new display 57 | doc = addImageDocument(viewer, img); 58 | 59 | % history 60 | tag = doc.Tag; 61 | string = sprintf('%s = Image.read(''%s'');\n', tag, imagePath); 62 | addToHistory(viewer, string); 63 | end 64 | end % end methods 65 | 66 | end % end classdef 67 | 68 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+file/SaveImage.m: -------------------------------------------------------------------------------- 1 | classdef SaveImage < imagem.actions.CurrentImageAction 2 | % Save the current image into a file. 3 | % 4 | % Class SaveImage 5 | % 6 | % Example 7 | % SaveImage 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SaveImage() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('Save current image'); 36 | 37 | % Open dialog to save image 38 | [fileName, pathName] = uiputfile( ... 39 | {'*.gif;*.jpg;*.jpeg;*.tif;*.tiff;*.bmp;*.hdr;*.dcm;*.mhd', ... 40 | 'All Image Files (*.tif, *.hdr, *.dcm, *.mhd, *.bmp, *.jpg)'; ... 41 | '*.tif;*.tiff', 'TIF Files (*.tif, *.tiff)'; ... 42 | '*.bmp', 'BMP Files (*.bmp)'; ... 43 | '*.hdr', 'Mayo Analyze Files (*.hdr)'; ... 44 | '*.dcm', 'DICOM Files (*.dcm)'; ... 45 | '*.mhd;*.mha', 'MetaImage data files (*.mha, *.mhd)'; ... 46 | '*.*', 'All Files (*.*)'}, ... 47 | 'Save Image'); 48 | 49 | if isequal(fileName,0) || isequal(pathName,0) 50 | return; 51 | end 52 | 53 | % try to save the current image 54 | doc = currentDoc(frame); 55 | img = doc.Image; 56 | try 57 | write(img, fullfile(pathName, fileName)); 58 | catch ex 59 | errordlg(ex.message, 'Image Writing Error', 'modal'); 60 | error(ex.message); 61 | end 62 | 63 | % add history 64 | string = sprintf('write(%s, ''%s'');\n', ... 65 | doc.Tag, fullfile(pathName, fileName)); 66 | addToHistory(frame, string); 67 | 68 | end % end actionPerformed 69 | 70 | end % end methods 71 | 72 | end % end classdef 73 | 74 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ClearImageOverlay.m: -------------------------------------------------------------------------------- 1 | classdef ClearImageOverlay < imagem.actions.CurrentImageAction 2 | % Remove all overlays of an image document. 3 | % 4 | % Class ClearImageOverlay 5 | % 6 | % Example 7 | % ClearImageOverlay 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-12, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ClearImageOverlay(varargin) 27 | % Constructor for ClearImageOverlay class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | disp('% clear overlay'); 39 | 40 | doc = currentDoc(frame); 41 | 42 | clearShapes(doc); 43 | 44 | updateDisplay(frame); 45 | end 46 | 47 | end % end methods 48 | 49 | end % end classdef 50 | 51 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ClearSpatialCalibration.m: -------------------------------------------------------------------------------- 1 | classdef ClearSpatialCalibration < imagem.actions.CurrentImageAction 2 | % Reset spatial calibration of current image to default values. 3 | % 4 | % Class ClearSpatialCalibration 5 | % 6 | % Example 7 | % ClearSpatialCalibration 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-08, using Matlab 9.7.0.1247435 (R2019b) Update 2 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ClearSpatialCalibration(varargin) 27 | % Constructor for ClearSpatialCalibration class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | img = currentImage(frame); 39 | 40 | clearCalibration(img); 41 | 42 | updateDisplay(frame); 43 | end 44 | 45 | end % end methods 46 | 47 | end % end classdef 48 | 49 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ConvertDataType.m: -------------------------------------------------------------------------------- 1 | classdef ConvertDataType < imagem.actions.ScalarImageAction 2 | % Convert data type of a scalar image. 3 | % 4 | % Class ConvertDataType 5 | % 6 | % Example 7 | % ConvertDataType 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-29, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | % The type of the data to convert to. 22 | % Can be one of {'uint8', 'uint16', 'float'}; 23 | TargetType = 'uint8'; 24 | 25 | end % end properties 26 | 27 | 28 | %% Constructor 29 | methods 30 | function obj = ConvertDataType(targetType) 31 | % Constructor for ConvertDataType class. 32 | obj.TargetType = targetType; 33 | 34 | end 35 | 36 | end % end constructors 37 | 38 | 39 | %% Methods 40 | methods 41 | function run(obj, frame) 42 | 43 | % retrieve data 44 | doc = currentDoc(frame); 45 | img = doc.Image; 46 | 47 | % process 48 | switch obj.TargetType 49 | case 'uint8' 50 | newType = 'grayscale'; 51 | img2 = Image('Data', uint8(img.Data), 'Parent', img, 'Type', newType); 52 | case 'uint16' 53 | newType = 'grayscale'; 54 | img2 = Image('Data', uint16(img.Data), 'Parent', img, 'Type', newType); 55 | case 'single' 56 | newType = 'intensity'; 57 | img2 = Image('Data', single(img.Data), 'Parent', img, 'Type', newType); 58 | otherwise 59 | error('Unknown type to convert: %s', obj.TargetType); 60 | end 61 | 62 | % add image to application, and create new display 63 | [newFrame, newDoc] = createImageFrame(frame, img2); 64 | newFrame.DisplayRange = frame.DisplayRange; 65 | 66 | % additional setup for 3D images 67 | if isa(frame, 'imagem.gui.Image3DSliceViewer') && isa(newFrame, 'imagem.gui.Image3DSliceViewer') 68 | updateSliceIndex(viewer, frame.SliceIndex); 69 | end 70 | 71 | % add history 72 | string = sprintf('%s = Image(''Data'', %s(%s.Data), ''Parent'', %s, ''Type'', ''%s'');\n', ... 73 | newDoc.Tag, obj.TargetType, doc.Tag, doc.Tag, newType); 74 | addToHistory(frame, string); 75 | end 76 | end % end methods 77 | 78 | end % end classdef 79 | 80 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ConvertImage3DToVectorImage.m: -------------------------------------------------------------------------------- 1 | classdef ConvertImage3DToVectorImage < imagem.actions.Image3DAction 2 | %CONVERTIMAGE3DTOVECTORIMAGE One-line description here, please. 3 | % 4 | % Class ConvertImage3DToVectorImage 5 | % 6 | % Example 7 | % ConvertImage3DToVectorImage 8 | % 9 | % See also 10 | % ConvertVectorImageToImage3D 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ConvertImage3DToVectorImage(varargin) 27 | % Constructor for ConvertImage3DToVectorImage class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = currentDoc(frame); 40 | 41 | % apply the conversion operation 42 | res = permute(doc.Image, [1 2 4 3 5]); 43 | 44 | % create a new doc 45 | newDoc = addImageDocument(frame, res); 46 | 47 | % add history 48 | string = sprintf('%s = permute(%s, [1 2 4 3 5]);\n', ... 49 | newDoc.Tag, doc.Tag); 50 | addToHistory(frame, string); 51 | end 52 | 53 | end % end methods 54 | 55 | end % end classdef 56 | 57 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ConvertRGBImageToGrayscale.m: -------------------------------------------------------------------------------- 1 | classdef ConvertRGBImageToGrayscale < imagem.actions.CurrentImageAction 2 | % One-line description here, please. 3 | % 4 | % Class ConvertRGBImageToGrayscale 5 | % 6 | % Example 7 | % ConvertRGBImageToGrayscale 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-04-08, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ConvertRGBImageToGrayscale(varargin) 27 | % Constructor for ConvertRGBImageToGrayscale class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | 41 | % check image type 42 | if ~isColorImage(doc.Image) 43 | errordlg('Requires a Color image', 'Image Format Error'); 44 | return; 45 | end 46 | 47 | % convert RGB image to grayscale image with uint8 data 48 | res = rgb2gray(doc.Image); 49 | 50 | % add new image to application, and create new display 51 | [frame2, doc2] = createImageFrame(frame, res); %#ok 52 | 53 | % add history 54 | string = sprintf('%s = rgb2gray(%s);\n', ... 55 | doc2.Tag, doc.Tag); 56 | addToHistory(frame, string); 57 | end 58 | 59 | 60 | function b = isActivable(obj, frame) %#ok 61 | doc = frame.Doc; 62 | b = ~isempty(doc) && ~isempty(doc.Image) && isColorImage(doc.Image); 63 | end 64 | 65 | end % end methods 66 | 67 | end % end classdef 68 | 69 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ConvertVectorImageToImage3D.m: -------------------------------------------------------------------------------- 1 | classdef ConvertVectorImageToImage3D < imagem.actions.CurrentImageAction 2 | % One-line description here, please. 3 | % 4 | % Class ConvertVectorImageToImage3D 5 | % 6 | % Example 7 | % ConvertVectorImageToImage3D 8 | % 9 | % See also 10 | % ConvertImage3DToVectorImage 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ConvertVectorImageToImage3D(varargin) 27 | % Constructor for ConvertVectorImageToImage3D class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = currentDoc(frame); 40 | 41 | % apply the conversion operation 42 | res = permute(doc.Image, [1 2 4 3 5]); 43 | 44 | % create a new doc 45 | newDoc = addImageDocument(frame, res); 46 | 47 | % add history 48 | string = sprintf('%s = permute(%s, [1 2 4 3 5]);\n', ... 49 | newDoc.Tag, doc.Tag); 50 | addToHistory(frame, string); 51 | end 52 | 53 | 54 | function b = isActivable(obj, frame) 55 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 56 | if b 57 | b = isVectorImage(currentImage(frame)); 58 | end 59 | end 60 | 61 | end % end methods 62 | 63 | end % end classdef 64 | 65 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ConvertVectorImageToRGB.m: -------------------------------------------------------------------------------- 1 | classdef ConvertVectorImageToRGB < imagem.actions.CurrentImageAction 2 | % Convert vector image to RGB image by selecting the three channels. 3 | % 4 | % Class ConvertVectorImageToRGB 5 | % 6 | % Example 7 | % ConvertVectorImageToRGB 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-25, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ConvertVectorImageToRGB(varargin) 27 | % Constructor for ConvertVectorImageToRGB class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = currentDoc(frame); 40 | 41 | img = doc.Image; 42 | if ~isVectorImage(img) 43 | errordlg('Requires a vector image'); 44 | return; 45 | end 46 | nc = channelCount(img); 47 | if nc < 3 48 | errordlg('Requires at least three channels in image'); 49 | return; 50 | end 51 | channelNames = cellstr(num2str((1:nc)', 'Channel %d')); 52 | 53 | % open a dialog to choose channel indices 54 | gd = imagem.gui.GenericDialog('Vector To RGB'); 55 | addChoice(gd, 'Red: ', channelNames, channelNames{1}); 56 | addChoice(gd, 'Green: ', channelNames, channelNames{2}); 57 | addChoice(gd, 'Blue: ', channelNames, channelNames{3}); 58 | % addCheckBox(gd, 'Adjust intensities', true); 59 | setSize(gd, [200 150]); 60 | 61 | showDialog(gd); 62 | if wasCanceled(gd) 63 | return; 64 | end 65 | 66 | indR = getNextChoiceIndex(gd); 67 | indG = getNextChoiceIndex(gd); 68 | indB = getNextChoiceIndex(gd); 69 | 70 | chR = adjustDynamic(channel(img, indR)); 71 | chG = adjustDynamic(channel(img, indG)); 72 | chB = adjustDynamic(channel(img, indB)); 73 | rgbData = uint8(cat(4, chR.Data, chG.Data, chB.Data)); 74 | 75 | % apply the conversion operation 76 | res = Image('Data', rgbData, 'parent', img, 'type', 'color'); 77 | 78 | 79 | % create a new doc 80 | newDoc = addImageDocument(frame, res); 81 | 82 | % % add history 83 | % string = sprintf('%s = Image(permute(%s.Data, [1 2 4 3 5]);\n', ... 84 | % newDoc.Tag, doc.Tag); 85 | % addToHistory(frame, string); 86 | end 87 | 88 | 89 | function b = isActivable(obj, frame) 90 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 91 | if b 92 | b = isVectorImage(currentImage(frame)); 93 | end 94 | end 95 | 96 | end % end methods 97 | 98 | end % end classdef 99 | 100 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/DuplicateImage.m: -------------------------------------------------------------------------------- 1 | classdef DuplicateImage < imagem.actions.CurrentImageAction 2 | % Duplicate the current image. 3 | % 4 | % Class DuplicateImageAction 5 | % 6 | % Example 7 | % DuplicateImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = DuplicateImage() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | image = clone(currentImage(frame)); 37 | 38 | % add image to application, and create new display 39 | [doc, viewer] = addImageDocument(frame, image); %#ok 40 | viewer.DisplayRange = frame.DisplayRange; 41 | 42 | % additional setup for 3D images 43 | if isa(frame, 'imagem.gui.Image3DSliceViewer') && isa(viewer, 'imagem.gui.Image3DSliceViewer') 44 | updateSliceIndex(viewer, frame.SliceIndex); 45 | end 46 | 47 | end 48 | end % end methods 49 | 50 | end % end classdef 51 | 52 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/EditChannelNames.m: -------------------------------------------------------------------------------- 1 | classdef EditChannelNames < imagem.actions.VectorImageAction 2 | % Edit channel names of a color or vector image. 3 | % 4 | % Class EditChannelNames 5 | % 6 | % Example 7 | % EditChannelNames 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-04, using Matlab 8.6.0.267246 (R2015b) 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | % list of handles on the dialog widgets 22 | Handles; 23 | 24 | Viewer; 25 | 26 | end % end properties 27 | 28 | 29 | %% Constructor 30 | methods 31 | function obj = EditChannelNames(varargin) 32 | % Constructor for EditChannelNames class 33 | 34 | end 35 | 36 | end % end constructors 37 | 38 | 39 | %% Methods 40 | methods 41 | function run(obj, frame) %#ok 42 | 43 | % get handle to current doc 44 | obj.Viewer = frame; 45 | img = currentImage(obj.Viewer); 46 | 47 | % retrieve channel names of current image, or create them if empty 48 | nc = channelCount(img); 49 | names = img.ChannelNames; 50 | if length(names) ~= nc 51 | names = cell(1, nc); 52 | end 53 | 54 | % creates a new dialog, and populates it with some fields 55 | gd = imagem.gui.GenericDialog('Edit Channel Names'); 56 | for ic = 1:nc 57 | addTextField(gd, sprintf('Channel %d: ', ic), names{ic}); 58 | end 59 | 60 | % displays the dialog, and waits for user 61 | showDialog(gd); 62 | 63 | % check if ok or cancel was clicked 64 | if wasCanceled(gd) 65 | return; 66 | end 67 | 68 | % retrieve new channel names 69 | newNames = cell(1, nc); 70 | for ic = 1:nc 71 | newNames{ic} = getNextString(gd); 72 | end 73 | 74 | % update image 75 | img.ChannelNames = newNames; 76 | 77 | % add history 78 | pattern = ['{''%s''' repmat(', ''%s''', 1, nc-1) '}']; 79 | namesString = sprintf(pattern, newNames{:}); 80 | string = sprintf('%s.ChannelNames = %s\n', ... 81 | obj.Viewer.Doc.Tag, namesString); 82 | addToHistory(obj.Viewer, string); 83 | end 84 | 85 | end % end methods 86 | 87 | end % end classdef 88 | 89 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/EditSpatialCalibration.m: -------------------------------------------------------------------------------- 1 | classdef EditSpatialCalibration < imagem.actions.CurrentImageAction 2 | % Edit spatial calibration info of current image. 3 | % 4 | % Class EditSpatialCalibration 5 | % 6 | % Example 7 | % EditSpatialCalibration 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-08, using Matlab 9.7.0.1247435 (R2019b) Update 2 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = EditSpatialCalibration(varargin) 27 | % Constructor for EditSpatialCalibration class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | img = currentImage(frame); 39 | 40 | nd = ndims(img); 41 | 42 | % create a new Dialog and populate with some fields 43 | gd = imagem.gui.GenericDialog('Spatial Calibration'); 44 | for i = 1:nd 45 | addNumericField(gd, sprintf('Spacing %d:', i), img.Spacing(i), 3); 46 | end 47 | for i = 1:nd 48 | addNumericField(gd, sprintf('Origin %d:', i), img.Origin(i), 3); 49 | end 50 | addTextField(gd, 'Unit Name:', img.UnitName); 51 | 52 | % displays the dialog, and waits for user 53 | showDialog(gd); 54 | % check if ok or cancel was clicked 55 | if wasCanceled(gd) 56 | return; 57 | end 58 | 59 | % parse user input 60 | sp = zeros(1, nd); 61 | or = zeros(1, nd); 62 | for i = 1:nd 63 | sp(i) = getNextNumber(gd); 64 | end 65 | for i = 1:nd 66 | or(i) = getNextNumber(gd); 67 | end 68 | unit = getNextString(gd); 69 | 70 | img.Spacing = sp; 71 | img.Origin = or; 72 | img.UnitName = unit; 73 | 74 | updateDisplay(frame); 75 | end 76 | 77 | end % end methods 78 | 79 | end % end classdef 80 | 81 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ExtractFrame.m: -------------------------------------------------------------------------------- 1 | classdef ExtractFrame < imagem.actions.TimeLapseImageAction 2 | % Extract a frame from a lime-lapse image. 3 | % 4 | % Class ExtractFrame 5 | % 6 | % Example 7 | % ExtractFrame 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ExtractFrame(varargin) 27 | % Constructor for ExtractFrame class 28 | end 29 | 30 | end % end constructors 31 | 32 | 33 | %% Methods 34 | methods 35 | function run(obj, viewer) %#ok 36 | 37 | % get handle to current doc 38 | doc = currentDoc(viewer); 39 | img = doc.Image; 40 | 41 | % determine current slice, and slice number 42 | currentFrame = viewer.FrameIndex; % assume class 'Image5DViewer' 43 | nFrames = frameNumber(img); 44 | 45 | % open a dialog to choose slice index 46 | gd = imagem.gui.GenericDialog('Extract Frame'); 47 | frameLabel = sprintf('Frame Index (max %d)', nFrames); 48 | addNumericField(gd, frameLabel, currentFrame, 0); 49 | setSize(gd, [300 100]); 50 | 51 | showDialog(gd); 52 | if wasCanceled(gd) 53 | return; 54 | end 55 | 56 | frameIndex = getNextNumber(gd); 57 | if frameIndex < 1 || frameIndex > nFrames 58 | error('frameIndex must be comprised between 1 and %d', nFrames); 59 | end 60 | 61 | % apply the conversion operation 62 | res = frame(img, frameIndex); 63 | if ~isempty(img.Name) 64 | nDigits = ceil(log10(nFrames)); 65 | pattern = ['%s_t%0' num2str(nDigits) 'd']; 66 | res.Name = sprintf(pattern, img.Name, frameIndex); 67 | end 68 | 69 | % create a new doc 70 | newDoc = addImageDocument(viewer, res); 71 | 72 | % add history 73 | string = sprintf('%s = frame(%s, %d));\n', ... 74 | newDoc.Tag, doc.Tag, frameIndex); 75 | addToHistory(viewer, string); 76 | end 77 | 78 | end % end methods 79 | 80 | end % end classdef 81 | 82 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ExtractSlice.m: -------------------------------------------------------------------------------- 1 | classdef ExtractSlice < imagem.actions.Image3DAction 2 | % Extract an XY slice from a 3D image. 3 | % 4 | % Class ExtractSlice 5 | % 6 | % Example 7 | % ExtractSlice 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ExtractSlice(varargin) 27 | % Constructor for ExtractSlice class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = currentDoc(frame); 40 | img = doc.Image; 41 | 42 | % determine current slice, and slice number 43 | currentSlice = frame.SliceIndex; % assume class 'Image3DSliceViewer' 44 | sliceNumber = size(img, 3); 45 | 46 | % open a dialog to choose slice index 47 | gd = imagem.gui.GenericDialog('Extract Slice'); 48 | sliceLabel = sprintf('Slice Index (max %d)', sliceNumber); 49 | addNumericField(gd, sliceLabel, currentSlice, 0); 50 | setSize(gd, [300 100]); 51 | 52 | showDialog(gd); 53 | if wasCanceled(gd) 54 | return; 55 | end 56 | 57 | sliceIndex = getNextNumber(gd); 58 | if sliceIndex < 1 || sliceIndex > sliceNumber 59 | error('sliceIndex must be comprised between 1 and %d', sliceNumber); 60 | end 61 | 62 | % apply the conversion operation 63 | res = slice(img, sliceIndex); 64 | if ~isempty(img.Name) 65 | nDigits = ceil(log10(sliceNumber)); 66 | pattern = ['%s_z%0' num2str(nDigits) 'd']; 67 | res.Name = sprintf(pattern, img.Name, sliceIndex); 68 | end 69 | 70 | % create a new doc 71 | newDoc = addImageDocument(frame, res); 72 | 73 | % add history 74 | string = sprintf('%s = slice(%s, %d);\n', ... 75 | newDoc.Tag, doc.Tag, sliceIndex); 76 | addToHistory(frame, string); 77 | end 78 | 79 | end % end methods 80 | 81 | end % end classdef 82 | 83 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/FlipImage.m: -------------------------------------------------------------------------------- 1 | classdef FlipImage < imagem.actions.CurrentImageAction 2 | % Flip current image. 3 | % 4 | % Class FlipImageAction 5 | % 6 | % Example 7 | % FlipImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-05-18, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | Axis = 3; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = FlipImage(axis) 28 | if nargin > 0 29 | obj.Axis = axis; 30 | end 31 | end 32 | 33 | end % end constructors 34 | 35 | 36 | %% Methods 37 | methods 38 | function run(obj, frame) %#ok 39 | 40 | % flip image 41 | doc = currentDoc(frame); 42 | res = flip(doc.Image, obj.Axis); 43 | 44 | % add image to application, and create new display 45 | newDoc = addImageDocument(frame, res); 46 | 47 | % add history 48 | string = sprintf('%s = flip(%s, %d);\n', ... 49 | newDoc.Tag, doc.Tag, obj.Axis); 50 | addToHistory(frame, string); 51 | end 52 | end 53 | 54 | end % end classdef 55 | 56 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ImageConvertType.m: -------------------------------------------------------------------------------- 1 | classdef ImageConvertType < imagem.actions.ScalarImageAction 2 | % Convert the type (grayscale, label...) of the current (scalar) image. 3 | % 4 | % Class ImageConvertTypeAction 5 | % 6 | % Example 7 | % ImageConvertTypeAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2016-01-06, using Matlab 8.6.0.267246 (R2015b) 16 | % Copyright 2016 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | TypeName; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = ImageConvertType(typeName) 28 | % Constructor for ImageConvertType class 29 | 30 | % init inner fields 31 | obj.TypeName = typeName; 32 | end 33 | 34 | end % end constructors 35 | 36 | 37 | %% Methods 38 | methods 39 | function run(obj, frame) %#ok 40 | if isempty(obj.TypeName) 41 | return; 42 | end 43 | 44 | % get handle to current doc 45 | doc = currentDoc(frame); 46 | 47 | % apply the conversion operation 48 | res = Image(doc.Image, 'Type', obj.TypeName); 49 | 50 | % create a new doc 51 | newDoc = addImageDocument(frame, res); 52 | 53 | % add history 54 | string = sprintf('%s = Image(%s, ''Type'', ''%s'');\n', ... 55 | newDoc.Tag, doc.Tag, obj.TypeName); 56 | addToHistory(frame, string); 57 | end 58 | end % end methods 59 | 60 | end % end classdef 61 | 62 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/InvertImage.m: -------------------------------------------------------------------------------- 1 | classdef InvertImage < imagem.actions.CurrentImageAction 2 | % Invert the current image. 3 | % 4 | % output = InvertImageAction(input) 5 | % 6 | % Example 7 | % InvertImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = InvertImage() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % get handle to viewer figure, and current doc 27 | doc = currentDoc(frame); 28 | 29 | % apply 'invert' operation 30 | img2 = invert(currentImage(frame)); 31 | 32 | % add image to application, and create new display 33 | newDoc = addImageDocument(frame, img2); 34 | 35 | % copy display settings 36 | newDoc.ColorMap = doc.ColorMap; 37 | newDoc.ColorMapName = doc.ColorMapName; 38 | newDoc.BackgroundColor = doc.BackgroundColor; 39 | 40 | % history 41 | string = sprintf('%s = invert(%s);\n', newDoc.Tag, doc.Tag); 42 | addToHistory(frame, string); 43 | end 44 | end 45 | 46 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/PermuteDimensions.m: -------------------------------------------------------------------------------- 1 | classdef PermuteDimensions < imagem.actions.CurrentImageAction 2 | % Re-order the dimensions of an image. 3 | % 4 | % Class PermuteDimensions 5 | % 6 | % Example 7 | % PermuteDimensions 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-02-14, using Matlab 8.6.0.267246 (R2015b) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = PermuteDimensions(varargin) 28 | % Constructor for PermuteDimensions class 29 | 30 | end 31 | 32 | end % end constructors 33 | 34 | 35 | %% Methods 36 | methods 37 | function run(obj, frame) %#ok 38 | 39 | % get handle to current doc 40 | doc = currentDoc(frame); 41 | img = doc.Image; 42 | 43 | % Create the string for ordering dimensions 44 | nd = 5; 45 | baseString = ['1' sprintf(repmat(', %d', 1, nd-1), 2:nd)]; 46 | 47 | % creates a new dialog, and populates it with some fields 48 | gd = imagem.gui.GenericDialog('Permute Dimensions'); 49 | 50 | addTextField(gd, 'New Order: ', baseString); 51 | 52 | % displays the dialog, and waits for user 53 | showDialog(gd); 54 | 55 | % check if ok or cancel was clicked 56 | if wasCanceled(gd) 57 | return; 58 | end 59 | 60 | % get dialog options 61 | orderString = getNextString(gd); 62 | tokens = strsplit(orderString, ', '); 63 | inds = str2num(char(tokens')); %#ok 64 | 65 | % create image with permuted dimensions 66 | res = permute(img, inds); 67 | 68 | % add image to application, and create new display 69 | [viewer2, doc2] = createImageFrame(frame.Gui, res); 70 | 71 | % keep display settings if channel dim stays the same 72 | if inds(4) == 4 73 | viewer2.DisplayRange = frame.DisplayRange; 74 | end 75 | 76 | % add history 77 | newDimsString = sprintf('[%d %d %d %d %d]', inds); 78 | string = sprintf('%s = permute(%s, %s);\n', ... 79 | doc2.Tag, doc.Tag, newDimsString); 80 | addToHistory(frame, string); 81 | end 82 | 83 | end % end methods 84 | 85 | end % end classdef 86 | 87 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/PrintImageInfo.m: -------------------------------------------------------------------------------- 1 | classdef PrintImageInfo < imagem.actions.CurrentImageAction 2 | % Print some info about current image. 3 | % 4 | % Class PrintImageInfo 5 | % 6 | % Example 7 | % PrintImageInfo 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-07, using Matlab 9.7.0.1247435 (R2019b) Update 2 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PrintImageInfo(varargin) 27 | % Constructor for PrintImageInfo class. 28 | end 29 | 30 | end % end constructors 31 | 32 | 33 | %% Methods 34 | methods 35 | function run(obj, frame) %#ok 36 | 37 | % flip image 38 | doc = currentDoc(frame); 39 | img = currentImage(frame); 40 | 41 | fprintf('Print image info for document %s\n', doc.Tag); 42 | fprintf(' Image name: %s\n', img.Name); 43 | fprintf(' File Path: %s\n', img.FilePath); 44 | 45 | sizePattern = ['%d' repmat('x%d', 1, ndims(img)-1)]; 46 | fprintf([' Size: ' sizePattern '\n'], size(img)); 47 | fprintf(' Type: %s\n', img.Type); 48 | 49 | if img.Calibrated 50 | fprintf(' Calibrated: true\n'); 51 | calibPattern = ['[%g' repmat(',%g', 1, ndims(img)-1) ']']; 52 | fprintf([' Origin: ' calibPattern '\n'], img.Origin); 53 | fprintf([' Spacing: ' calibPattern '\n'], img.Spacing); 54 | fprintf(' Unit Name: %s\n', img.UnitName); 55 | else 56 | fprintf(' Calibrated: false\n'); 57 | end 58 | 59 | if ~isempty(img.AxisNames) 60 | fprintf(' Axis Names: {''%s''', img.AxisNames{1}); 61 | for i = 2:length(img.AxisNames) 62 | fprintf(',''%s''', img.AxisNames{i}); 63 | end 64 | fprintf('}\n'); 65 | else 66 | fprintf(' Axis Names: {}\n'); 67 | end 68 | 69 | if ~isempty(img.ChannelNames) 70 | fprintf(' Channel Names: {''%s''', img.ChannelNames{1}); 71 | nc = channelCount(img); 72 | if nc > 10 73 | for i = 2:10 74 | fprintf(', ''%s''', img.ChannelNames{i}); 75 | end 76 | fprintf('... (%d more)}\n', nc-10); 77 | else 78 | for i = 2:nc 79 | fprintf(', ''%s''', img.ChannelNames{i}); 80 | end 81 | fprintf('}\n'); 82 | end 83 | else 84 | fprintf(' Channel Names: {}\n'); 85 | end 86 | end 87 | end % end methods 88 | 89 | end % end classdef 90 | 91 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/RenameImage.m: -------------------------------------------------------------------------------- 1 | classdef RenameImage < imagem.actions.CurrentImageAction 2 | % Rename the current image. 3 | % 4 | % Class RenameImageAction 5 | % 6 | % Example 7 | % RenameImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = RenameImage() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % extract app data 37 | image = currentImage(frame); 38 | app = frame.Gui.App; 39 | 40 | % setup widget options 41 | prompt = {'New image name:'}; 42 | name = 'Rename current image'; 43 | numLines = 1; 44 | defaultAnswer = {image.Name}; 45 | 46 | while true 47 | % ask for a new image name 48 | answer = inputdlg(prompt, name, numLines, defaultAnswer); 49 | if isempty(answer) 50 | return; 51 | end 52 | newName = answer{1}; 53 | 54 | % if new name is valid, update title and escape 55 | if ~hasDocumentWithName(app, newName) || strcmp(newName, image.Name) 56 | image.Name = newName; 57 | updateTitle(frame); 58 | return; 59 | end 60 | 61 | % if name already exists, re-display dialog until valid name 62 | h = errordlg(... 63 | sprintf('An image with name ''%s'' already exists', newName), ... 64 | 'Image Name error', 'modal'); 65 | uiwait(h); 66 | defaultAnswer = {newName}; 67 | end 68 | 69 | end 70 | end % end methods 71 | 72 | end % end classdef 73 | 74 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ReorderChannels.m: -------------------------------------------------------------------------------- 1 | classdef ReorderChannels < imagem.actions.VectorImageAction 2 | % Change order of channels of a vector image. 3 | % 4 | % Class ReorderChannels 5 | % 6 | % Example 7 | % ReorderChannels 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-04, using Matlab 8.6.0.267246 (R2015b) 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | % list of handles on the dialog widgets 22 | Handles; 23 | 24 | Viewer; 25 | 26 | end % end properties 27 | 28 | 29 | %% Constructor 30 | methods 31 | function obj = ReorderChannels(varargin) 32 | % Constructor for ReorderChannels class 33 | 34 | end 35 | 36 | end % end constructors 37 | 38 | 39 | %% Methods 40 | methods 41 | function run(obj, frame) %#ok 42 | % disp('Compute Image median filter'); 43 | 44 | % get handle to current doc 45 | obj.Viewer = frame; 46 | img = currentImage(obj.Viewer); 47 | 48 | % Create the string for ordering labels 49 | nChannels = channelNumber(img); 50 | baseString = ['1' sprintf(repmat(',%d', 1, nChannels-1), 2:nChannels)]; 51 | 52 | % creates a new dialog, and populates it with some fields 53 | gd = imagem.gui.GenericDialog('Edit Channel Names'); 54 | obj.Handles.Dialog = gd; 55 | 56 | addTextField(gd, 'New Order: ', baseString); 57 | 58 | % displays the dialog, and waits for user 59 | showDialog(gd); 60 | 61 | % check if ok or cancel was clicked 62 | if wasCanceled(gd) 63 | return; 64 | end 65 | 66 | % get dialog options 67 | orderString = getNextString(gd); 68 | tokens = strsplit(orderString, ', '); 69 | inds = str2num(char(tokens')); %#ok 70 | 71 | res = Image('data', img.Data(:,:,:,inds,:), ... 72 | 'parent', img, ... 73 | 'ChannelNames', img.ChannelNames(inds)); 74 | 75 | % add image to application, and create new display 76 | [doc2, viewer2] = addImageDocument(frame, res); %#ok 77 | viewer2.DisplayRange = frame.DisplayRange; 78 | 79 | % additional setup for 3D images 80 | if isa(frame, 'imagem.gui.Image3DSliceViewer') && isa(viewer, 'imagem.gui.Image3DSliceViewer') 81 | updateSliceIndex(viewer2, frame.SliceIndex); 82 | end 83 | 84 | % % add history 85 | % string = sprintf('%s = medianFilter(%s, ones(%d,%d));\n', ... 86 | % newDoc.Tag, doc.Tag, width, height); 87 | % addToHistory(obj.Viewer, string); 88 | end 89 | 90 | end % end methods 91 | 92 | end % end classdef 93 | 94 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/ReshapeImage.m: -------------------------------------------------------------------------------- 1 | classdef ReshapeImage < imagem.actions.CurrentImageAction 2 | % Reshape current image. 3 | % 4 | % Class ReshapeImageAction 5 | % 6 | % Example 7 | % ReshapeImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-05-18, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ReshapeImage() 27 | % Constructor for the ReshapeImage action. 28 | end 29 | 30 | end % end constructors 31 | 32 | 33 | %% Methods 34 | methods 35 | function run(obj, frame) %#ok 36 | 37 | % get current image 38 | doc = currentDoc(frame); 39 | img = doc.Image; 40 | 41 | dims = size(img, 1:5); 42 | ZCT = prod(dims(3:5)); 43 | newDims = dims; 44 | 45 | while true 46 | % create dialog 47 | gd = imagem.gui.GenericDialog('Reshape Image'); 48 | addNumericField(gd, 'Size X:', newDims(1), 0); 49 | addNumericField(gd, 'Size Y:', newDims(2), 0); 50 | addNumericField(gd, 'Size Z:', newDims(3), 0); 51 | addNumericField(gd, 'Channels (C):', newDims(4), 0); 52 | addNumericField(gd, 'Frames (T):', newDims(5), 0); 53 | addMessage(gd, sprintf('ZxCxT must equal %d', ZCT)); 54 | 55 | showDialog(gd); 56 | if wasCanceled(gd) 57 | return; 58 | end 59 | 60 | % parse dialog options 61 | newDims = zeros([1 5]); 62 | newDims(1) = getNextNumber(gd); 63 | newDims(2) = getNextNumber(gd); 64 | newDims(3) = getNextNumber(gd); 65 | newDims(4) = getNextNumber(gd); 66 | newDims(5) = getNextNumber(gd); 67 | 68 | if prod(newDims) == prod(dims) 69 | break; 70 | end 71 | end 72 | 73 | res = reshape(img, newDims); 74 | 75 | % add image to application, and create new display 76 | [newFrame, newDoc] = createImageFrame(frame.Gui, res); %#ok 77 | 78 | % add history 79 | newShapeString = sprintf('[%d %d %d %d %d]', newDims); 80 | string = sprintf('%s = reshape(%s, %s);\n', ... 81 | newDoc.Tag, doc.Tag, newShapeString); 82 | addToHistory(frame, string); 83 | end 84 | end 85 | 86 | end % end classdef 87 | 88 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/RotateImage90.m: -------------------------------------------------------------------------------- 1 | classdef RotateImage90 < imagem.actions.CurrentImageAction 2 | % Rotate current image by 90 degrees. 3 | % 4 | % Class RotateImage90 5 | % 6 | % Example 7 | % RotateImage90 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-05-18, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | Number = 1; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = RotateImage90(varargin) 28 | if ~isempty(varargin) 29 | obj.Number = varargin{1}; 30 | end 31 | end 32 | 33 | end % end constructors 34 | 35 | 36 | %% Methods 37 | methods 38 | function run(obj, frame) %#ok 39 | 40 | % get handle to current doc 41 | doc = currentDoc(frame); 42 | 43 | % flip image 44 | res = rotate90(doc.Image, obj.Number); 45 | 46 | % add image to application, and create new display 47 | newDoc = addImageDocument(frame, res); 48 | 49 | % history 50 | string = sprintf('%s = rotate90(%s, %d);\n', ... 51 | newDoc.Tag, doc.Tag, obj.Number); 52 | addToHistory(frame, string); 53 | end 54 | end 55 | 56 | end % end classdef 57 | 58 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/SetBrushSize.m: -------------------------------------------------------------------------------- 1 | classdef SetBrushSize < imagem.gui.Action 2 | % Change the size of the brush. 3 | % 4 | % Class SetBrushSizeAction 5 | % 6 | % Example 7 | % SetBrushSizeAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SetBrushSize() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | methods 33 | function run(obj, frame) %#ok 34 | disp('set brush size'); 35 | 36 | answer = inputdlg(... 37 | 'Enter the brush size (in pixels):', ... 38 | 'Input Brush size', ... 39 | 1, {num2str(frame.Gui.App.BrushSize)}); 40 | 41 | if isempty(answer) 42 | return; 43 | end 44 | 45 | size = str2double(answer{1}); 46 | if isnan(size) 47 | errordlg('Could not understand brush size'); 48 | end 49 | 50 | frame.Gui.App.BrushSize = size; 51 | end 52 | 53 | end 54 | 55 | end % end classdef 56 | 57 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/SetBrushValue.m: -------------------------------------------------------------------------------- 1 | classdef SetBrushValue < imagem.gui.Action 2 | % Change the value of the brush. 3 | % 4 | % Class SetBrushValue 5 | % 6 | % Example 7 | % SetBrushValue 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-01-30, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SetBrushValue() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | methods 33 | function run(obj, frame) %#ok 34 | disp('set brush value'); 35 | 36 | answer = inputdlg(... 37 | 'Enter the brush value:', ... 38 | 'Input Brush size', ... 39 | 1, {num2str(frame.Gui.App.BrushValue)}); 40 | 41 | if isempty(answer) 42 | return; 43 | end 44 | 45 | size = str2double(answer{1}); 46 | if isnan(size) 47 | errordlg('Could not understand brush value'); 48 | end 49 | 50 | frame.Gui.App.BrushValue = size; 51 | end 52 | 53 | end 54 | 55 | end % end classdef 56 | 57 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/SetChannelDisplayType.m: -------------------------------------------------------------------------------- 1 | classdef SetChannelDisplayType < imagem.actions.VectorImageAction 2 | %SETCHANNELDISPLAYTYPE One-line description here, please. 3 | % 4 | % Class SetChannelDisplayType 5 | % 6 | % Example 7 | % SetChannelDisplayType 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2020-01-28, using Matlab 9.7.0.1247435 (R2019b) Update 2 16 | % Copyright 2020 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | DisplayType; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = SetChannelDisplayType(displayType) 28 | % Constructor for SetChannelDisplayType class 29 | 30 | % init inner fields 31 | obj.DisplayType = displayType; 32 | end 33 | 34 | end % end constructors 35 | 36 | 37 | %% Methods 38 | methods 39 | function run(obj, frame) %#ok 40 | if isempty(obj.DisplayType) 41 | return; 42 | end 43 | 44 | % get handle to current doc 45 | doc = currentDoc(frame); 46 | 47 | doc.ChannelDisplayType = obj.DisplayType; 48 | end 49 | end % end methods 50 | 51 | end % end classdef 52 | 53 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/SplitImageChannels.m: -------------------------------------------------------------------------------- 1 | classdef SplitImageChannels < imagem.actions.VectorImageAction 2 | % Split the channels from a multi-channel image. 3 | % 4 | % Class SplitImageChannelsAction 5 | % 6 | % Example 7 | % SplitImageChannelsAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-05, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Constructor 20 | methods 21 | function obj = SplitImageChannels() 22 | end 23 | 24 | end % end constructors 25 | 26 | 27 | %% Methods 28 | methods 29 | function run(obj, frame) %#ok 30 | disp('Split Image channels'); 31 | 32 | % get handle to current doc 33 | doc = frame.Doc; 34 | 35 | if ~isVectorImage(doc.Image) 36 | errordlg('Requires a Vector image', 'Image Format Error'); 37 | return; 38 | end 39 | 40 | % extract the different channels 41 | channels = splitChannels(doc.Image); 42 | 43 | % add new images to application, and create new displays 44 | for i = 1:length(channels) 45 | addImageDocument(frame, channels{i}); 46 | end 47 | 48 | end 49 | end % end methods 50 | 51 | end % end classdef 52 | 53 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+image/SplitImageRGB.m: -------------------------------------------------------------------------------- 1 | classdef SplitImageRGB < imagem.actions.CurrentImageAction 2 | % Split the three channels from a color image. 3 | % 4 | % Class SplitImageRGBAction 5 | % 6 | % Example 7 | % SplitImageRGBAction 8 | % 9 | % See also 10 | % SplitImageChannelsAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2011-12-05, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Constructor 21 | methods 22 | function obj = SplitImageRGB() 23 | end 24 | 25 | end % end constructors 26 | 27 | 28 | %% Methods 29 | methods 30 | function run(obj, frame) %#ok 31 | 32 | % get handle to current doc 33 | doc = frame.Doc; 34 | 35 | if ~isColorImage(doc.Image) 36 | errordlg('Requires a Color image', 'Image Format Error'); 37 | return; 38 | end 39 | 40 | % extract the different channels in three image instances 41 | [red, green, blue] = splitChannels(doc.Image); 42 | 43 | % add new images to application, and create new displays 44 | docR = addImageDocument(frame, red); 45 | docG = addImageDocument(frame, green); 46 | docB = addImageDocument(frame, blue); 47 | 48 | % add history 49 | string = sprintf('[%s, %s, %s] = splitChannels(%s);\n', ... 50 | docR.Tag, docG.Tag, docB.Tag, doc.Tag); 51 | addToHistory(frame, string); 52 | end 53 | 54 | end % end methods 55 | 56 | methods 57 | function b = isActivable(obj, frame) %#ok 58 | doc = frame.Doc; 59 | b = ~isempty(doc) && ~isempty(doc.Image) && isColorImage(doc.Image); 60 | end 61 | end 62 | 63 | end % end classdef 64 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/+binary/BinaryImageOverlay.m: -------------------------------------------------------------------------------- 1 | classdef BinaryImageOverlay < imagem.gui.Action 2 | % Apply binary overlay over current image. 3 | % 4 | % Class ImageOverlayAction 5 | % 6 | % Example 7 | % ImageOverlayAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = BinaryImageOverlay() 27 | end 28 | 29 | end % end constructors 30 | 31 | methods 32 | function run(obj, frame) %#ok 33 | 34 | app = frame.Gui.App; 35 | imageNames = getImageNames(app); 36 | colorNames = imagem.util.enums.BasicColors.allLabels; 37 | 38 | % Creates the Dialog for choosing options 39 | gd = imagem.gui.GenericDialog('Binary Overlay'); 40 | addChoice(gd, 'Reference Image:', imageNames, imageNames{1}); 41 | addChoice(gd, 'Binary Image:', imageNames, imageNames{1}); 42 | addChoice(gd, 'Overlay Color:', colorNames, colorNames{1}); 43 | 44 | % displays the dialog, and waits for user 45 | showDialog(gd); 46 | % check if ok or cancel was clicked 47 | if wasCanceled(gd) 48 | return; 49 | end 50 | 51 | % parse user inputs 52 | refDoc = getDocument(app, getNextString(gd)); 53 | binDoc = getDocument(app, getNextString(gd)); 54 | colorItem = imagem.util.enums.BasicColors.fromLabel(getNextString(gd)); 55 | color = colorItem.RGB; 56 | 57 | % retrieve images 58 | refImg = refDoc.Image; 59 | binImg = binDoc.Image; 60 | 61 | % check inputs 62 | if ~isBinaryImage(binImg) 63 | error('Overlay Image must be binary'); 64 | end 65 | if ndims(refImg) ~= ndims(binImg) 66 | error('Input images must have same dimension'); 67 | end 68 | if any(size(refImg) ~= size(binImg)) 69 | error('Input images must have same size'); 70 | end 71 | 72 | ovr = overlay(refImg, binImg, color); 73 | name = 'NoName-ovr'; 74 | if ~isempty(refImg.Name) 75 | name = [refImg.Name '-ovr']; 76 | end 77 | ovr.Name = name; 78 | 79 | % add image to application, and create new display 80 | newDoc = addImageDocument(frame, ovr); 81 | 82 | % add history 83 | string = sprintf('%s = overlay(%s, %s, [%g %g %g]);\n', ... 84 | newDoc.Tag, refDoc.Tag, binDoc.Tag, color); 85 | addToHistory(frame, string); 86 | end 87 | 88 | end 89 | 90 | end % end classdef 91 | 92 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/+binary/ConnectedComponentsLabeling.m: -------------------------------------------------------------------------------- 1 | classdef ConnectedComponentsLabeling < imagem.actions.BinaryImageAction 2 | % Connected Components Labeling of a binary image. 3 | % 4 | % Class ConnectedComponentsLabeling 5 | % 6 | % Example 7 | % ConnectedComponentsLabeling 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-18, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ConnectedComponentsLabeling() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to current doc 37 | doc = currentDoc(frame); 38 | 39 | lbl = componentLabeling(doc.Image); 40 | 41 | newDoc = addImageDocument(frame, lbl); 42 | 43 | % history 44 | string = sprintf('%s = componentLabeling(%s);\n', newDoc.Tag, doc.Tag); 45 | addToHistory(frame, string); 46 | end 47 | 48 | end % end methods 49 | 50 | end % end classdef 51 | 52 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/+binary/ImageSkeleton.m: -------------------------------------------------------------------------------- 1 | classdef ImageSkeleton < imagem.actions.BinaryImageAction 2 | % Computes skeleton of a binary image. 3 | % 4 | % Class ImageSkeletonAction 5 | % 6 | % Example 7 | % ImageSkeletonAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageSkeleton() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to viewer figure, and current doc 37 | doc = currentDoc(frame); 38 | 39 | % compute Image skeleton 40 | img2 = skeleton(doc.Image); 41 | 42 | % add image to application, and create new display 43 | newDoc = addImageDocument(frame, img2); 44 | 45 | % history 46 | string = sprintf('%s = skeleton(%s);\n', newDoc.Tag, doc.Tag); 47 | addToHistory(frame, string); 48 | 49 | end 50 | end % end methods 51 | 52 | end % end classdef 53 | 54 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/+binary/KeepLargestRegion.m: -------------------------------------------------------------------------------- 1 | classdef KeepLargestRegion < imagem.actions.CurrentImageAction 2 | % Keep the largest region within a binary image. 3 | % 4 | % Class keepLargestRegionAction 5 | % 6 | % Example 7 | % keepLargestRegionAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-05-25, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = KeepLargestRegion() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to viewer figure, and current doc 37 | doc = currentDoc(frame); 38 | 39 | % compute Image skeleton 40 | img2 = largestRegion(doc.Image); 41 | 42 | % add image to application, and create new display 43 | newDoc = addImageDocument(frame, img2); 44 | 45 | % history 46 | string = sprintf('%s = largestRegion(%s);\n', newDoc.Tag, doc.Tag); 47 | addToHistory(frame, string); 48 | end 49 | end % end methods 50 | 51 | methods 52 | function b = isActivable(obj, frame) 53 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 54 | if b 55 | img = currentImage(frame); 56 | binFlag = isBinaryImage(img); 57 | lblFlag = isLabelImage(img); 58 | b = b && (binFlag || lblFlag); 59 | end 60 | end 61 | end 62 | 63 | end % end classdef 64 | 65 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/AdjustImageDynamic.m: -------------------------------------------------------------------------------- 1 | classdef AdjustImageDynamic < imagem.actions.ScalarImageAction 2 | % Adjust dynamic of current image. 3 | % 4 | % output = ImageAdjustDynamicAction(input) 5 | % 6 | % Example 7 | % ImageAdjustDynamicAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-08, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = AdjustImageDynamic() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | disp('Adjust image dynamic'); 26 | 27 | % apply 'norm' operation 28 | img2 = adjustDynamic(currentImage(frame)); 29 | 30 | % add image to application, and create new display 31 | addImageDocument(frame, img2); 32 | end 33 | end 34 | 35 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ApplyImageFunction.m: -------------------------------------------------------------------------------- 1 | classdef ApplyImageFunction < imagem.actions.CurrentImageAction 2 | % Apply a method to Image object, and display result. 3 | % 4 | % output = ApplyImageFunctionAction(input) 5 | % 6 | % Example 7 | % ApplyImageFunctionAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-22, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | MethodName; 20 | end 21 | 22 | methods 23 | function obj = ApplyImageFunction(methodName) 24 | % calls the parent constructor 25 | obj.MethodName = methodName; 26 | end 27 | end 28 | 29 | methods 30 | function run(obj, frame) %#ok 31 | if isempty(obj.MethodName) 32 | return; 33 | end 34 | 35 | % get handle to current doc 36 | doc = currentDoc(frame); 37 | 38 | % apply the given operation 39 | res = feval(obj.MethodName, doc.Image ~= 0); 40 | 41 | % depending on result type, should do different processes 42 | if isa(res, 'Image') 43 | newDoc = addImageDocument(frame, res); 44 | else 45 | error('Image expected'); 46 | end 47 | 48 | % add history 49 | string = sprintf('%s = %s(%s);\n', ... 50 | newDoc.Tag, obj.MethodName, doc.Tag); 51 | addToHistory(frame, string); 52 | 53 | end 54 | end 55 | 56 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/FillImageHoles.m: -------------------------------------------------------------------------------- 1 | classdef FillImageHoles < imagem.actions.ScalarImageAction 2 | % Fill holes within a binary or scalar image. 3 | % 4 | % Class FillImageHolesAction 5 | % 6 | % Example 7 | % FillImageHolesAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-05-25, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = FillImageHoles() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to viewer figure, and current doc 37 | doc = currentDoc(frame); 38 | 39 | % compute Image skeleton 40 | img2 = fillHoles(doc.Image); 41 | 42 | % add image to application, and create new display 43 | newDoc = addImageDocument(frame, img2); 44 | 45 | % add history 46 | string = sprintf('%s = fillHoles(%s, %d);\n', ... 47 | newDoc.Tag, doc.Tag, ... 48 | getDefaultConnectivity(frame.Gui.App, ndims(img2))); 49 | addToHistory(frame, string); 50 | end 51 | end % end methods 52 | 53 | end % end classdef 54 | 55 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageAutoThresholdOtsu.m: -------------------------------------------------------------------------------- 1 | classdef ImageAutoThresholdOtsu < imagem.actions.ScalarImageAction 2 | % Threshold image using Otsu method. 3 | % 4 | % output = ImageAutoThresholdOtsuAction(input) 5 | % 6 | % Example 7 | % ImageAutoThresholdOtsuAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-04-17, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageAutoThresholdOtsu(varargin) 20 | % calls the parent constructor 21 | obj = obj@imagem.actions.ScalarImageAction(varargin{:}); 22 | end 23 | end 24 | 25 | methods 26 | function run(obj, frame) %#ok 27 | 28 | % get handle to current doc 29 | doc = currentDoc(frame); 30 | 31 | % apply 'gradient' operation 32 | bin = otsuThreshold(doc.Image); 33 | 34 | % add image to application, and create new display 35 | newDoc = addImageDocument(frame, bin); 36 | 37 | % add history 38 | string = sprintf('%s = otsuThreshold(%s);\n', newDoc.Tag, doc.Tag); 39 | addToHistory(frame, string); 40 | 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageClosing.m: -------------------------------------------------------------------------------- 1 | classdef ImageClosing < imagem.actions.CurrentImageAction 2 | % Morphological closing on current image. 3 | % 4 | % output = ImageClosing(input) 5 | % 6 | % Example 7 | % ImageClosing 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-09, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageClosing() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | % apply 'closing' operation 26 | 27 | % get handle to current doc 28 | doc = currentDoc(frame); 29 | 30 | se = ones(3, 3); 31 | 32 | img2 = closing(doc.Image, se); 33 | 34 | % add image to application, and create new display 35 | newDoc = addImageDocument(frame, img2); 36 | 37 | % add history 38 | string = sprintf('%s = closing(%s, ones(3,3));\n', ... 39 | newDoc.Tag, doc.Tag); 40 | addToHistory(frame, string); 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageDilation.m: -------------------------------------------------------------------------------- 1 | classdef ImageDilation < imagem.actions.CurrentImageAction 2 | % Morpohlogical dilation of current image. 3 | % 4 | % output = ImageDilation(input) 5 | % 6 | % Example 7 | % ImageDilation 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-09, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageDilation() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | % apply morphological dilation operation 26 | 27 | % get handle to current doc 28 | doc = currentDoc(frame); 29 | 30 | % compute dilation 31 | se = ones(3, 3); 32 | img2 = dilation(doc.Image, se); 33 | 34 | % add image to application, and create new display 35 | newDoc = addImageDocument(frame, img2); 36 | 37 | % add history 38 | string = sprintf('%s = dilation(%s, ones(3,3));\n', ... 39 | newDoc.Tag, doc.Tag); 40 | addToHistory(frame, string); 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageErosion.m: -------------------------------------------------------------------------------- 1 | classdef ImageErosion < imagem.actions.CurrentImageAction 2 | % Morphological erosion of current image. 3 | % 4 | % output = ImageErosion(input) 5 | % 6 | % Example 7 | % ImageDilationAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-09, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageErosion() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | % Compute Image erosion 26 | 27 | % get handle to current doc 28 | doc = currentDoc(frame); 29 | 30 | se = ones(3, 3); 31 | 32 | % compute result image 33 | img2 = erosion(doc.Image, se); 34 | 35 | % add image to application, and create new display 36 | newDoc = addImageDocument(frame, img2); 37 | 38 | % add history 39 | string = sprintf('%s = erosion(%s, ones(3,3));\n', ... 40 | newDoc.Tag, doc.Tag); 41 | addToHistory(frame, string); 42 | end 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageGradientVector.m: -------------------------------------------------------------------------------- 1 | classdef ImageGradientVector < imagem.actions.ScalarImageAction 2 | % Compute gradient of current image as vector image. 3 | % 4 | % output = ImageGradientVectorAction(input) 5 | % 6 | % Example 7 | % ImageGradientVectorAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-02-27, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageGradientVector() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % get handle to current doc 27 | doc = currentDoc(frame); 28 | 29 | % apply 'gradient' operation 30 | grad = gradient(doc.Image); 31 | 32 | % add image to application, and create new display 33 | newDoc = addImageDocument(frame, grad); 34 | 35 | % add history 36 | string = sprintf('%s = gradient(%s);\n', newDoc.Tag, doc.Tag); 37 | addToHistory(frame, string); 38 | end 39 | end 40 | 41 | 42 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageMaxEntropyThreshold.m: -------------------------------------------------------------------------------- 1 | classdef ImageMaxEntropyThreshold < imagem.actions.ScalarImageAction 2 | % Threshold a grayscale image using max entropy method. 3 | % 4 | % output = ImageMaxEntropyThresholdAction(input) 5 | % 6 | % Example 7 | % ImageMaxEntropyThresholdAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-04-17, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageMaxEntropyThreshold(varargin) 20 | % calls the parent constructor 21 | obj = obj@imagem.actions.ScalarImageAction(varargin{:}); 22 | end 23 | end 24 | 25 | methods 26 | function run(obj, frame) %#ok 27 | 28 | % get handle to current doc and image 29 | doc = currentDoc(frame); 30 | img = doc.Image; 31 | 32 | % apply 'threshold' operation 33 | bin = maxEntropyThreshold(img); 34 | 35 | % add image to application, and create new display 36 | [frame2, newDoc] = createImageFrame(frame, bin); %#ok 37 | 38 | % add history 39 | string = sprintf('%s = maxEntropyThreshold(%s);\n', newDoc.Tag, doc.Tag); 40 | addToHistory(frame, string); 41 | 42 | end 43 | end 44 | 45 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageMorphoGradient.m: -------------------------------------------------------------------------------- 1 | classdef ImageMorphoGradient < imagem.actions.ScalarImageAction 2 | % Apply morphological gradient (Beucher Gradient) on current image. 3 | % 4 | % Class ImageMorphoGradientAction 5 | % 6 | % Example 7 | % ImageMorphoGradientAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-15, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageMorphoGradient() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('Compute Image morphological gradient'); 36 | 37 | % get handle to current doc 38 | doc = currentDoc(frame); 39 | 40 | % apply 'gradient' operation 41 | se = ones(3, 3); 42 | img2 = morphoGradient(doc.Image, se); 43 | 44 | % add image to application, and create new display 45 | newDoc = addImageDocument(frame, img2); 46 | 47 | % add history 48 | string = sprintf('%s = morphoGradient(%s, ones(3,3));\n', ... 49 | newDoc.Tag, doc.Tag); 50 | addToHistory(frame, string); 51 | end 52 | end % end methods 53 | 54 | end % end classdef 55 | 56 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageMorphologicalFilter.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattools/ImageM/58c455f5c0c5d8f48bf9094cf4d2d4bdce9f4598/ImageM/+imagem/+actions/+process/ImageMorphologicalFilter.m -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageOpening.m: -------------------------------------------------------------------------------- 1 | classdef ImageOpening < imagem.actions.CurrentImageAction 2 | % Apply morphological opening on current image. 3 | % 4 | % output = ImageOpening(input) 5 | % 6 | % Example 7 | % ImageOpening 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-09, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ImageOpening() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | % Compute Image opening 26 | 27 | % get handle to current doc 28 | doc = currentDoc(frame); 29 | 30 | % compute result image 31 | se = ones(3, 3); 32 | img2 = opening(doc.Image, se); 33 | 34 | % add image to application, and create new display 35 | newDoc = addImageDocument(frame, img2); 36 | 37 | % add history 38 | string = sprintf('%s = opening(%s, ones(3,3));\n', ... 39 | newDoc.Tag, doc.Tag); 40 | addToHistory(frame, string); 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageOrthogonalProjection.m: -------------------------------------------------------------------------------- 1 | classdef ImageOrthogonalProjection < imagem.actions.ScalarImageAction 2 | % Project image intensities along one of the main directions. 3 | % 4 | % Class ImageOrthogonalProjection 5 | % 6 | % Example 7 | % ImageOrthogonalProjection 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-27, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageOrthogonalProjection(varargin) 27 | % Constructor for ImageOrthogonalProjection class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % open dialog 39 | gd = imagem.gui.GenericDialog('Orthogonal Projection'); 40 | addNumericField(gd, 'Proj. Direction: ', 3, 0); 41 | addChoice(gd, 'Operation: ', {'Max.', 'Min.', 'Mean'}, 'Max.'); 42 | 43 | % displays the dialog, and waits for user 44 | showDialog(gd); 45 | % check if ok or cancel was clicked 46 | if wasCanceled(gd) 47 | return; 48 | end 49 | 50 | % parse user input 51 | dirIndex = getNextNumber(gd); 52 | if dirIndex < 1 || dirIndex > 5 53 | error('Projection Direction must be comprised between 1 and 5'); 54 | end 55 | projTypeIndex = getNextChoiceIndex(gd); 56 | opNameList = {'max', 'min', 'mean'}; 57 | opName = opNameList{projTypeIndex}; 58 | 59 | % retrieve data 60 | doc = frame.Doc; 61 | img = doc.Image; 62 | 63 | % compute projection 64 | proj = squeeze(orthogonalProjection(img, dirIndex, opName)); 65 | 66 | [newFrame, newDoc] = createImageFrame(frame, proj); %#ok 67 | 68 | % add history 69 | string = sprintf('%s = squeeze(orthogonalProjection(%s, %d, ''%s''));\n', ... 70 | newDoc.Tag, doc.Tag, dirIndex, opName); 71 | addToHistory(frame, string); 72 | 73 | end 74 | end % end methods 75 | 76 | end % end classdef 77 | 78 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageRegionalMaxima.m: -------------------------------------------------------------------------------- 1 | classdef ImageRegionalMaxima < imagem.actions.ScalarImageAction 2 | % Extract extended maxima in a grayscale image. 3 | % 4 | % output = ImageRegionalMaximaAction(input) 5 | % 6 | % Example 7 | % ImageRegionalMaximaAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-11, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | end 20 | 21 | methods 22 | function obj = ImageRegionalMaxima() 23 | end 24 | end 25 | 26 | methods 27 | function run(obj, frame) %#ok 28 | % apply regional maxima to current image 29 | 30 | % get handle to viewer figure, and current doc 31 | img = currentImage(frame); 32 | 33 | if ~isScalarImage(img) 34 | warning('ImageM:WrongImageType', ... 35 | 'Regional maxima can be applied only on scalar images'); 36 | return; 37 | end 38 | 39 | app = frame.Gui.App; 40 | conn = getDefaultConnectivity(app, ndims(img)); 41 | bin = regionalMaxima(img, conn); 42 | 43 | newDoc = addImageDocument(frame.Gui, bin, [], 'rmax'); 44 | 45 | % add history 46 | string = sprintf('%s = regionalMaxima(%s, %d);\n', ... 47 | newDoc.Tag, frame.Doc.Tag, conn); 48 | addToHistory(frame, string); 49 | 50 | end 51 | end 52 | 53 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageRegionalMinima.m: -------------------------------------------------------------------------------- 1 | classdef ImageRegionalMinima < imagem.actions.ScalarImageAction 2 | % Extract regional minima in a grayscale image. 3 | % 4 | % output = ImageRegionalMinimaAction(input) 5 | % 6 | % Example 7 | % ImageRegionalMinimaAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-11, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | end 20 | 21 | methods 22 | function obj = ImageRegionalMinima() 23 | end 24 | end 25 | 26 | methods 27 | function run(obj, frame) %#ok 28 | % apply regional minima to current image 29 | 30 | img = currentImage(frame); 31 | if ~isScalarImage(img) 32 | warning('ImageM:WrongImageType', ... 33 | 'Regional minima can be applied only on scalar images'); 34 | return; 35 | end 36 | 37 | app = frame.Gui.App; 38 | conn = getDefaultConnectivity(app, ndims(img)); 39 | bin = regionalMinima(img, conn); 40 | 41 | [frame2, newDoc] = createImageFrame(frame, bin); %#ok 42 | 43 | % add history 44 | string = sprintf('%s = regionalMinima(%s, %d);\n', ... 45 | newDoc.Tag, frame.Doc.Tag, conn); 46 | addToHistory(frame, string); 47 | end 48 | end 49 | 50 | 51 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/ImageReplaceValue.m: -------------------------------------------------------------------------------- 1 | classdef ImageReplaceValue < imagem.actions.CurrentImageAction 2 | % Replace one or several values within an image by a new value. 3 | % 4 | % Class ImageReplaceValue 5 | % 6 | % Example 7 | % ImageReplaceValue 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-07-31, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageReplaceValue(varargin) 27 | % Constructor for ImageReplaceValue class. 28 | obj = obj@imagem.actions.CurrentImageAction(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | 41 | gd = imagem.gui.GenericDialog('Replace values'); 42 | addTextField(gd, 'Old value(s): ', '1'); 43 | addTextField(gd, 'New value: ', '0'); 44 | 45 | % displays the dialog, and waits for user 46 | showDialog(gd); 47 | % check if ok or cancel was clicked 48 | if wasCanceled(gd) 49 | return; 50 | end 51 | 52 | % gets the user inputs 53 | oldValuesStr = getNextString(gd); 54 | strList = strtrim(strsplit(oldValuesStr, ',')); 55 | oldValues = zeros(1, length(strList)); 56 | for i = 1:length(strList) 57 | oldValues(i) = parseValue(strList{i}); 58 | end 59 | 60 | newValueStr = getNextString(gd); 61 | newValue = parseValue(newValueStr); 62 | 63 | doc.Image(ismember(doc.Image, oldValues)) = newValue; 64 | 65 | doc.Modified = true; 66 | 67 | updateDisplay(frame); 68 | 69 | % update history 70 | nValues = length(oldValues); 71 | pattern = ['[%g' repmat(' %g', 1, nValues-1) ']']; 72 | str1 = sprintf(pattern, oldValues); 73 | tag = doc.Tag; 74 | string = sprintf('%s(ismember(%s, %s)) = %g;\n', tag, tag, str1, newValue); 75 | addToHistory(frame, string); 76 | 77 | % utility function to parse a numeric value 78 | function val = parseValue(str) 79 | val = str2num(str); %#ok 80 | if isempty(val) 81 | error(['Could not parse value: ' str]); 82 | end 83 | end 84 | end 85 | 86 | function b = isActivable(obj, frame) %#ok 87 | % Check if current doc contains a scalar image. 88 | doc = frame.Doc; 89 | b = ~isempty(doc) && ~isempty(doc.Image); 90 | if b 91 | b = isScalarImage(doc.Image); 92 | end 93 | end 94 | end % end methods 95 | 96 | end % end classdef 97 | 98 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/KillImageBorders.m: -------------------------------------------------------------------------------- 1 | classdef KillImageBorders < imagem.actions.CurrentImageAction 2 | % Kill borders of a binary image. 3 | % 4 | % Class KillImageBordersAction 5 | % 6 | % Example 7 | % KillImageBordersAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2012-05-25, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = KillImageBorders() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to current doc 37 | doc = currentDoc(frame); 38 | img = currentImage(frame); 39 | 40 | % kill image borders 41 | img2 = killBorders(img); 42 | 43 | % add image to application, and create new display 44 | newDoc = addImageDocument(frame, img2); 45 | 46 | % history 47 | string = sprintf('%s = killBorders(%s);\n', newDoc.Tag, doc.Tag); 48 | addToHistory(frame, string); 49 | end 50 | end % end methods 51 | 52 | methods 53 | function b = isActivable(obj, frame) 54 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 55 | if b 56 | img = currentImage(frame); 57 | grayFlag = isGrayscaleImage(img); 58 | lblFlag = isLabelImage(img); 59 | b = b && (grayFlag || lblFlag); 60 | end 61 | end 62 | end 63 | 64 | end % end classdef 65 | 66 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+process/VectorImageNorm.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageNorm < imagem.actions.VectorImageAction 2 | % Compute norm of current (multi-channel) image. 3 | % 4 | % output = VectorImageNorm(input) 5 | % 6 | % Example 7 | % VectorImageNorm 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = VectorImageNorm() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % get handle to current doc 27 | doc = currentDoc(frame); 28 | 29 | % apply 'norm' operation 30 | img2 = norm(doc.Image); 31 | 32 | % add image to application, and create new display 33 | newDoc = addImageDocument(frame, img2); 34 | 35 | % add history 36 | string = sprintf('%s = norm(%s);\n', newDoc.Tag, doc.Tag); 37 | addToHistory(frame, string); 38 | end 39 | end 40 | 41 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/ChoosePreferredPlotTypes.m: -------------------------------------------------------------------------------- 1 | classdef ChoosePreferredPlotTypes < imagem.actions.CurrentTableAction 2 | % One-line description here, please. 3 | % 4 | % Class ChoosePreferredPlotTypes 5 | % 6 | % Example 7 | % ChoosePreferredPlotTypes 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-07-01, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ChoosePreferredPlotTypes(varargin) 27 | % Constructor for ChoosePreferredPlotTypes class. 28 | obj = obj@imagem.actions.CurrentTableAction(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | table = frame.Doc.Table; 39 | 40 | currentType = table.PreferredPlotTypes{1}; 41 | typeList = {'Line', 'Bar', 'StairSteps', 'Stem'}; 42 | 43 | index = find(strcmpi(currentType, typeList)); 44 | if isempty(index) 45 | error('invalid preferred plot type'); 46 | end 47 | 48 | % creates a new dialog, and populates it with some fields 49 | gd = imagem.gui.GenericDialog('Choose Plot Types'); 50 | addChoice(gd, 'Type: ', typeList, typeList{index}); 51 | 52 | % displays the dialog, and waits for user 53 | showDialog(gd); 54 | % check if ok or cancel was clicked 55 | if wasCanceled(gd) 56 | return; 57 | end 58 | 59 | % gets the user inputs 60 | type = getNextString(gd); 61 | 62 | nc = size(table, 2); 63 | table.PreferredPlotTypes = repmat({type}, 1, nc); 64 | 65 | end 66 | 67 | end % end methods 68 | 69 | end % end classdef 70 | 71 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/Concatenate.m: -------------------------------------------------------------------------------- 1 | classdef Concatenate < imagem.actions.CurrentTableAction 2 | % Concatenate tables, either horizontally or vertically. 3 | % 4 | % Class Concatenate 5 | % 6 | % Example 7 | % Concatenate 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | Handles; 22 | Frame; 23 | 24 | TableNameList; 25 | end % end properties 26 | 27 | 28 | %% Constructor 29 | methods 30 | function obj = Concatenate(varargin) 31 | % Constructor for Concatenate class 32 | 33 | end 34 | 35 | end % end constructors 36 | 37 | 38 | %% Methods 39 | methods 40 | function run(obj, frame) %#ok 41 | 42 | obj.Frame = frame; 43 | 44 | % initialize clas fields 45 | app = frame.Gui.App; 46 | obj.TableNameList = getTableNames(app); 47 | if length(obj.TableNameList) < 2 48 | errordlg('Requires At least two table frames', 'modal'); 49 | return; 50 | end 51 | 52 | directions = {'Columns', 'Rows'}; 53 | 54 | gd = imagem.gui.GenericDialog('Concatenate Tables'); 55 | addChoice(gd, 'Direction: ', directions, directions{1}); 56 | addChoice(gd, 'Table 1: ', obj.TableNameList, obj.TableNameList{1}); 57 | addChoice(gd, 'Table 2: ', obj.TableNameList, obj.TableNameList{2}); 58 | 59 | showDialog(gd); 60 | if wasCanceled(gd) 61 | return; 62 | end 63 | 64 | dirIndex = getNextChoiceIndex(gd); 65 | name1 = getNextString(gd); 66 | name2 = getNextString(gd); 67 | 68 | doc1 = getTableDocument(app, name1); 69 | doc2 = getTableDocument(app, name2); 70 | 71 | if dirIndex == 1 72 | % concatenate columns 73 | res = [doc1.Table doc2.Table]; 74 | catStr = ' '; 75 | else 76 | % concatenate rows 77 | res = [doc1.Table ; doc2.Table]; 78 | catStr = ' ; '; 79 | end 80 | 81 | % create document containing the new image 82 | [newFrame, newDoc] = createTableFrame(frame.Gui, res); %#ok 83 | 84 | % add history 85 | string = sprintf('%s = [%s%s%s];\n', ... 86 | newDoc.Tag, doc1.Tag, catStr, doc2.Tag); 87 | addToHistory(obj.Frame, string); 88 | 89 | end 90 | end % end methods 91 | 92 | end % end classdef 93 | 94 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/FilterFromColumnValues.m: -------------------------------------------------------------------------------- 1 | classdef FilterFromColumnValues < imagem.actions.CurrentTableAction 2 | % Select rows in a table based on a logical condition on column values. 3 | % 4 | % Class FilterFromColumnValues 5 | % 6 | % Example 7 | % FilterFromColumnValues 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-12-23, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = FilterFromColumnValues(varargin) 27 | % Constructor for FilterFromColumnValues class. 28 | obj = obj@imagem.actions.CurrentTableAction(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % retrieve data 39 | gui = frame.Gui; 40 | table = frame.Doc.Table; 41 | 42 | % initialize table name 43 | tableName = 'Table'; 44 | if ~isempty(tableName) 45 | tableName = [table.Name '-sel']; 46 | end 47 | 48 | % identify numeric columns 49 | inds = ~isFactor(table, 1:size(table, 2)); 50 | colNames = table.ColNames(inds); 51 | 52 | % get labels for operators 53 | opLabels = imagem.util.enums.RelationalOperators.allLabels; 54 | 55 | % creates a new dialog, and populates it with some fields 56 | gd = imagem.gui.GenericDialog('Filter Table from values'); 57 | addChoice(gd, 'Column: ', colNames, colNames{1}); 58 | addChoice(gd, 'Operation: ', opLabels, opLabels{1}); 59 | addNumericField(gd, 'Value: ', 0); 60 | addTextField(gd, 'New Table Name: ', tableName); 61 | 62 | % displays the dialog, and waits for user 63 | showDialog(gd); 64 | % check if ok or cancel was clicked 65 | if wasCanceled(gd) 66 | return; 67 | end 68 | 69 | % parse the user inputs 70 | colName = getNextString(gd); 71 | op = imagem.util.enums.RelationalOperators.fromLabel(getNextString(gd)); 72 | value = getNextNumber(gd); 73 | tableName = getNextString(gd); 74 | 75 | % select the rows that fullfil the condition 76 | column = table(:, colName); 77 | inds = apply(op, column.Data, value); 78 | 79 | % create new tables 80 | tab2 = table(inds, :); 81 | tab2.Name = tableName; 82 | [frame2, doc2] = createTableFrame(gui, tab2, frame); 83 | 84 | % add to history 85 | string = sprintf('%s = %s(%s(''%s'') %s %d, :);\n', ... 86 | doc2.Tag, frame.Doc.Tag, frame.Doc.Tag, colName, op.Symbol, value); 87 | addToHistory(frame2, string); 88 | string = sprintf('%s.Name = ''%s'';\n', doc2.Tag, tableName); 89 | addToHistory(frame2, string); 90 | end 91 | end % end methods 92 | 93 | end % end classdef 94 | 95 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/RenameTable.m: -------------------------------------------------------------------------------- 1 | classdef RenameTable < imagem.actions.CurrentTableAction 2 | % Change the name of the current table. 3 | % 4 | % Class RenameTable 5 | % 6 | % Example 7 | % RenameTable 8 | % 9 | % See also 10 | % tblui.TableGuiAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2012 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = RenameTable() 28 | % Constructor for RenameTableAction class 29 | obj = obj@imagem.actions.CurrentTableAction(); 30 | end 31 | 32 | end % end constructors 33 | 34 | 35 | %% Methods 36 | methods 37 | function run(obj, frame) %#ok 38 | 39 | table = frame.Doc.Table; 40 | 41 | answer = inputdlg({'Enter the new table name:'}, ... 42 | 'Change Table Name', ... 43 | 1, ... 44 | {table.Name}); 45 | 46 | if isempty(answer) 47 | return; 48 | end 49 | 50 | % get new name 51 | newName = answer{1}; 52 | 53 | % setup new name 54 | table.Name = newName; 55 | updateTitle(frame); 56 | 57 | % add history 58 | string = sprintf('%s.Name = ''%s'';\n', ... 59 | frame.Doc.Tag, newName); 60 | addToHistory(frame, string); 61 | 62 | end 63 | end % end methods 64 | 65 | end % end classdef 66 | 67 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/SelectTableColumns.m: -------------------------------------------------------------------------------- 1 | classdef SelectTableColumns < imagem.actions.CurrentTableAction 2 | % Select several columns and create new table. 3 | % 4 | % Class SelectTableColumns 5 | % 6 | % Example 7 | % SelectTableColumns 8 | % 9 | % See also 10 | % tblui.TableGui 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2012 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = SelectTableColumns(viewer) 28 | % Constructor for SelectTableColumnsAction class 29 | obj = obj@imagem.actions.CurrentTableAction(); 30 | end 31 | 32 | end % end constructors 33 | 34 | 35 | %% Methods 36 | methods 37 | function run(obj, frame) %#ok 38 | 39 | % retrieve data 40 | gui = frame.Gui; 41 | table = frame.Doc.Table; 42 | 43 | % open dialog to select relevant columns 44 | [sel, ok] = listdlg('ListString', table.ColNames, ... 45 | 'Name', 'Select Columns', ... 46 | 'PromptString', 'Select the columns:', ... 47 | 'ListSize', gui.Options.DlgListSize, ... 48 | 'selectionmode', 'multiple'); 49 | 50 | % check cancel 51 | if ~ok || isempty(sel) 52 | return; 53 | end 54 | 55 | % create new table 56 | tab2 = table(:, sel); 57 | [frame2, doc2] = createTableFrame(gui, tab2, frame); 58 | 59 | % add history 60 | indsString = ['[' num2str(sel(:)', '%d ') ']']; 61 | string = sprintf('%s = %s(:, %s);\n', ... 62 | doc2.Tag, frame.Doc.Tag, indsString); 63 | addToHistory(frame2, string); 64 | end 65 | end % end methods 66 | 67 | end % end classdef 68 | 69 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/SelectTableRows.m: -------------------------------------------------------------------------------- 1 | classdef SelectTableRows < imagem.actions.CurrentTableAction 2 | % Select several rows and create new table. 3 | % 4 | % Class SelectTableRowsAction 5 | % 6 | % Example 7 | % SelectTableRowsAction 8 | % 9 | % See also 10 | % tblui.TableGuiAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2012 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = SelectTableRows() 28 | % Constructor for SelectTableRowsAction class 29 | obj = obj@imagem.actions.CurrentTableAction(); 30 | end 31 | 32 | end % end constructors 33 | 34 | 35 | %% Methods 36 | methods 37 | function run(obj, frame) %#ok 38 | 39 | gui = frame.Gui; 40 | table = frame.Doc.Table; 41 | 42 | [sel, ok] = listdlg('ListString', table.RowNames, ... 43 | 'Name', 'Select Rows', ... 44 | 'PromptString', 'Select the rows:', ... 45 | 'ListSize', gui.Options.DlgListSize, ... 46 | 'selectionmode', 'multiple'); 47 | 48 | if ~ok || isempty(sel) 49 | return; 50 | end 51 | 52 | tab2 = table(sel, :); 53 | [frame2, doc2] = createTableFrame(gui, tab2); 54 | 55 | % add history 56 | indsString = ['[' num2str(sel(:)', '%d ') ']']; 57 | string = sprintf('%s = %s(%s, :);\n', ... 58 | doc2.Tag, frame.Doc.Tag, indsString); 59 | addToHistory(frame2, string); 60 | end 61 | end % end methods 62 | 63 | end % end classdef 64 | 65 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+edit/Transpose.m: -------------------------------------------------------------------------------- 1 | classdef Transpose < imagem.actions.CurrentTableAction 2 | % Transpose the current table. 3 | % 4 | % Class Transpose 5 | % 6 | % Example 7 | % Transpose 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = Transpose(varargin) 27 | % Constructor for Transpose class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | tab = doc.Table; 41 | 42 | tab2 = transpose(tab); 43 | 44 | [frame, doc2] = createTableFrame(frame.Gui, tab2); 45 | 46 | % add history 47 | string = sprintf('%s = transpose(%s);\n', ... 48 | doc2.Tag, doc.Tag); 49 | addToHistory(frame, string); 50 | end 51 | 52 | end % end methods 53 | 54 | end % end classdef 55 | 56 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+file/SaveTable.m: -------------------------------------------------------------------------------- 1 | classdef SaveTable < imagem.actions.CurrentTableAction 2 | % Save the current image into a file. 3 | % 4 | % Class SaveTable 5 | % 6 | % Example 7 | % SaveTable 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SaveTable() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('Save current table'); 36 | 37 | % Open dialog to save image 38 | [fileName, pathName] = uiputfile( ... 39 | {'*.txt;*.csv', ... 40 | 'All Table Files (*.txt, *.csv)'; ... 41 | '*.txt', 'Text Files (*.txt)'; ... 42 | '*.tsv', 'Tab-Separated values (*.csv)'; ... 43 | '*.csv', 'Comma-Separated values (*.csv)'; ... 44 | '*.*', 'All Files (*.*)'}, ... 45 | 'Save Table'); 46 | 47 | if isequal(fileName,0) || isequal(pathName,0) 48 | return; 49 | end 50 | 51 | % try to save the current image 52 | doc = currentDoc(frame); 53 | tab = doc.Table; 54 | try 55 | write(tab, fullfile(pathName, fileName)); 56 | catch ex 57 | errordlg(ex.message, 'Image Writing Error', 'modal'); 58 | return; 59 | end 60 | 61 | % add history 62 | string = sprintf('write(%s, ''%s'');\n', ... 63 | doc.Tag, fullfile(pathName, fileName)); 64 | addToHistory(frame, string); 65 | 66 | end % end actionPerformed 67 | 68 | end % end methods 69 | 70 | end % end classdef 71 | 72 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/BoxPlot.m: -------------------------------------------------------------------------------- 1 | classdef BoxPlot < imagem.actions.CurrentTableAction 2 | %Box Plot 3 | % 4 | % Class BoxPlot 5 | % 6 | % Example 7 | % BoxPlot 8 | % 9 | % See also 10 | % imagem.actions.CurrentTableAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 17 | % Copyright 2019 INRA - BIA-BIBS. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = BoxPlot(viewer) 28 | % Constructor for BoxPlot class 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % retrieve current table 39 | gui = frame.Gui; 40 | table = frame.Doc.Table; 41 | 42 | % opens a dialog to select features to display 43 | [indVar, ok] = listdlg('ListString', table.ColNames, ... 44 | 'Name', 'Box Plot', ... 45 | 'PromptString', 'Variables to display:', ... 46 | 'ListSize', gui.Options.DlgListSize, ... 47 | 'SelectionMode', 'multiple'); 48 | 49 | if ~ok || isempty(indVar) 50 | return; 51 | end 52 | 53 | % open a new frame for plotting 54 | createPlotFrame(gui); 55 | boxplot(table(:, indVar)); 56 | end 57 | 58 | end % end methods 59 | 60 | end % end classdef 61 | 62 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/GroupBoxPlot.m: -------------------------------------------------------------------------------- 1 | classdef GroupBoxPlot < imagem.actions.CurrentTableAction 2 | % GROUPBOXPLOTACTION 3 | % 4 | % Class GroupBoxPlot 5 | % 6 | % Example 7 | % GroupBoxPlot 8 | % 9 | % See also 10 | % imagem.actions.CurrentTableAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 17 | % Copyright 2019 INRA - BIA-BIBS. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = GroupBoxPlot() 28 | % Constructor for GroupBoxPlot class 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | gui = frame.Gui; 38 | table = frame.Doc.Table; 39 | 40 | [indVar, ok] = listdlg('ListString', table.ColNames, ... 41 | 'Name', 'BoxPlot', ... 42 | 'PromptString', 'Variable to display:', ... 43 | 'ListSize', gui.Options.DlgListSize, ... 44 | 'SelectionMode', 'Single'); 45 | 46 | if ~ok || isempty(indVar) 47 | return; 48 | end 49 | 50 | [indGroup, ok] = listdlg('ListString', table.ColNames, ... 51 | 'Name', 'BoxPlot', ... 52 | 'PromptString', 'Grouping variable:', ... 53 | 'ListSize', gui.Options.DlgListSize, ... 54 | 'SelectionMode', 'Single'); 55 | 56 | if ~ok || isempty(indGroup) 57 | return; 58 | end 59 | 60 | createPlotFrame(gui); 61 | 62 | boxplot(table(:, indVar), table(:, indGroup)); 63 | 64 | end 65 | end % end methods 66 | 67 | end % end classdef 68 | 69 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/PlotColumnHistogram.m: -------------------------------------------------------------------------------- 1 | classdef PlotColumnHistogram < imagem.actions.CurrentTableAction 2 | % Histogram of the values within the selected column of a table. 3 | % 4 | % Class PlotColumnHistogram 5 | % 6 | % Example 7 | % PlotColumnHistogram 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-12-07, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PlotColumnHistogram(varargin) 27 | % Constructor for PlotColumnHistogram class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % retrieve data 39 | gui = frame.Gui; 40 | table = frame.Doc.Table; 41 | 42 | % create a dialog to select column from its name 43 | [indVar, ok] = listdlg('ListString', table.ColNames, ... 44 | 'Name', 'Histogram', ... 45 | 'PromptString', 'Column to display:', ... 46 | 'ListSize', gui.Options.DlgListSize, ... 47 | 'SelectionMode', 'single'); 48 | 49 | % check the click on the "OK" button 50 | if ~ok || isempty(indVar) 51 | return; 52 | end 53 | 54 | % prepare graphics 55 | createPlotFrame(gui); 56 | 57 | % plot the histogram 58 | histogram(table(:, indVar)); 59 | end 60 | 61 | end % end methods 62 | 63 | end % end classdef 64 | 65 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/PlotColumns.m: -------------------------------------------------------------------------------- 1 | classdef PlotColumns < imagem.actions.CurrentTableAction 2 | % Plot selected columns of the current table. 3 | % 4 | % Class PlotSelectedColumns 5 | % 6 | % Example 7 | % PlotSelectedColumns 8 | % 9 | % See also 10 | % tblui.TableGuiAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 17 | % Copyright 2019 INRA - BIA-BIBS. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = PlotColumns() 28 | % Constructor for PlotSelectedColumns class 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | table = frame.Doc.Table; 39 | 40 | [sel, ok] = listdlg('ListString', table.ColNames, ... 41 | 'Name', 'Plot Histogram', ... 42 | 'PromptString', 'Columns To Plot:', ... 43 | 'ListSize', frame.Gui.Options.DlgListSize, ... 44 | 'SelectionMode', 'Multiple'); 45 | 46 | if ~ok || isempty(sel) 47 | return; 48 | end 49 | 50 | 51 | createPlotFrame(frame.Gui); 52 | 53 | plot(table(:, sel)); 54 | 55 | end 56 | end % end methods 57 | 58 | end % end classdef 59 | 60 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/PlotCorrelationCircles.m: -------------------------------------------------------------------------------- 1 | classdef PlotCorrelationCircles < imagem.actions.CurrentTableAction 2 | % Pair-wise scatter plot of table columns. 3 | % 4 | % Class PlotCorrelationCircles 5 | % 6 | % Example 7 | % PlotCorrelationCircles 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-12-23, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PlotCorrelationCircles(varargin) 27 | % Constructor for PlotCorrelationCircles class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | table = frame.Doc.Table; 39 | 40 | % identify numeric columns 41 | inds = ~isFactor(table, 1:size(table, 2)); 42 | colNames = table.ColNames(inds); 43 | 44 | % Open a dialog for choosing the columns to display 45 | [numColInds, ok] = listdlg(... 46 | 'ListString', colNames, ... 47 | 'Name', 'Correlation Circles', ... 48 | 'PromptString', 'Columns To Plot:', ... 49 | 'ListSize', frame.Gui.Options.DlgListSize, ... 50 | 'SelectionMode', 'Multiple'); 51 | 52 | if ~ok || isempty(numColInds) 53 | return; 54 | end 55 | 56 | % create Plot Pair display 57 | createPlotFrame(frame.Gui); 58 | correlationCircles(table(:, numColInds)); 59 | 60 | % create pattern for writing history 61 | numColNames = table.ColNames(numColInds); 62 | nc = length(numColNames); 63 | pattern = ['{''%s''' repmat(', ''%s''', 1, nc-1) '}']; 64 | numColsString = sprintf(pattern, numColNames{:}); 65 | 66 | % add to history 67 | string = sprintf('figure; correlationCircles(%s(%s));\n', ... 68 | frame.Doc.Tag, numColsString); 69 | addToHistory(frame, string); 70 | 71 | end 72 | end % end methods 73 | 74 | end % end classdef 75 | 76 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/PlotRows.m: -------------------------------------------------------------------------------- 1 | classdef PlotRows < imagem.actions.CurrentTableAction 2 | % Plot all rows of the current table. 3 | % 4 | % 5 | % output = Truxx(input) 6 | % 7 | % Example 8 | % Truxx 9 | % 10 | % See also 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 17 | % Copyright 2019 INRA - Cepia Software Platform. 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PlotRows() 27 | % Constructor for PlotRows class 28 | end 29 | 30 | end % end constructors 31 | 32 | 33 | %% Methods 34 | methods 35 | function run(obj, frame) %#ok 36 | 37 | % get handle to current doc 38 | doc = frame.Doc; 39 | tab = doc.Table; 40 | 41 | figure; plotRows(tab); 42 | end 43 | end % end methods 44 | 45 | 46 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+plot/ViolinPlot.m: -------------------------------------------------------------------------------- 1 | classdef ViolinPlot < imagem.actions.CurrentTableAction 2 | % Violin plot of features within a table. 3 | % 4 | % Class ViolinPlot 5 | % 6 | % Example 7 | % ViolinPlot 8 | % 9 | % See also 10 | % imagem.actions.CurrentTableAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2019-11-26, using Matlab 9.7.0.1190202 (R2019b) 17 | % Copyright 2019 INRA - BIA-BIBS. 18 | 19 | 20 | %% Properties 21 | properties 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = ViolinPlot(viewer) 28 | % Constructor for ViolinPlot class 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % retrieve current table 39 | gui = frame.Gui; 40 | table = frame.Doc.Table; 41 | 42 | % opens a dialog to select features to display 43 | [indVar, ok] = listdlg('ListString', table.ColNames, ... 44 | 'Name', 'ViolinPlot', ... 45 | 'PromptString', 'Variables to display:', ... 46 | 'ListSize', gui.Options.DlgListSize, ... 47 | 'SelectionMode', 'multiple'); 48 | 49 | if ~ok || isempty(indVar) 50 | return; 51 | end 52 | 53 | % open a new frame for plotting 54 | createPlotFrame(gui); 55 | violinPlot(table(:, indVar)); 56 | 57 | end 58 | end % end methods 59 | 60 | end % end classdef 61 | 62 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+process/Nmf.m: -------------------------------------------------------------------------------- 1 | classdef Nmf < imagem.gui.Action 2 | % Non-negative matrix factorization of current table. 3 | % 4 | % Class Nmf 5 | % 6 | % Example 7 | % Nmf 8 | % 9 | % See also 10 | % 11 | % 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-04-09, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = Nmf() 27 | % Constructor for TablePcaAction class 28 | obj = obj@imagem.gui.Action(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | if isempty(frame.Doc) 39 | return; 40 | end 41 | table = frame.Doc.Table; 42 | 43 | % default number of components 44 | nComps = min(5, size(table, 2)); 45 | 46 | % open a dialog to choose number of components 47 | prompt = {'Number of components:'}; 48 | title = 'Non-Negative Matrix Factorization'; 49 | dims = [1 35]; 50 | definput = {num2str(nComps)}; 51 | answer = inputdlg(prompt, title, dims, definput); 52 | 53 | % check user did not cancel 54 | if isempty(answer) 55 | return; 56 | end 57 | 58 | % parse user input 59 | nComps = str2double(answer{1}); 60 | if isnan(nComps) 61 | error('Could not interpret the number of components from string: %s', answer{1}); 62 | end 63 | 64 | [W, H] = nmf(table, nComps); 65 | 66 | % create a new frame for weights 67 | [frameW, docW] = createTableFrame(frame.Gui, W); %#ok 68 | 69 | % create a new frame for coefficients 70 | [frameH, docH] = createTableFrame(frame.Gui, H); %#ok 71 | 72 | 73 | % update history 74 | historyString = sprintf('[%s, %s] = nmf(%s, %d);\n', ... 75 | docW.Tag, docH.Tag, frame.Doc.Tag, nComps); 76 | addToHistory(frame, historyString); 77 | 78 | end 79 | end % end methods 80 | 81 | end % end classdef 82 | 83 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+process/Pca.m: -------------------------------------------------------------------------------- 1 | classdef Pca < imagem.gui.Action 2 | % Compute principal component analysis of current table. 3 | % 4 | % Class TablePcaAction 5 | % 6 | % Example 7 | % TablePcaAction 8 | % 9 | % See also 10 | % 11 | % 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@grignon.inra.fr 15 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = Pca() 27 | % Constructor for TablePcaAction class 28 | obj = obj@imagem.gui.Action(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | if isempty(frame.Doc) 39 | return; 40 | end 41 | table = frame.Doc.Table; 42 | 43 | % open a dioalog to set up PCA options and launch computation 44 | imagem.actions.table.process.PcaDialog(frame.Gui, table, frame); 45 | end 46 | end % end methods 47 | 48 | end % end classdef 49 | 50 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/+process/TableKMeans.m: -------------------------------------------------------------------------------- 1 | classdef TableKMeans < imagem.actions.CurrentTableAction 2 | %Apply K-means clustering on the current table. 3 | % 4 | % Class TableKMeans 5 | % 6 | % Example 7 | % TableKMeans 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = TableKMeans(varargin) 27 | % Constructor for TableKMeans class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | tab = doc.Table; 41 | 42 | % default options 43 | nClasses = 3; 44 | maxClassNumber = size(tab, 1); 45 | 46 | % open a dialog to choose slice index 47 | gd = imagem.gui.GenericDialog('K-Means'); 48 | numberLabel = 'Class number: '; 49 | addNumericField(gd, numberLabel, nClasses, 0); 50 | addCheckBox(gd, 'Display Centroids', true); 51 | addCheckBox(gd, 'Plot Result', true); 52 | setSize(gd, [200 150]); 53 | 54 | showDialog(gd); 55 | if wasCanceled(gd) 56 | return; 57 | end 58 | 59 | nClasses = getNextNumber(gd); 60 | if nClasses < 1 || nClasses > maxClassNumber 61 | error('sliceIndex must be comprised between 1 and %d', maxClassNumber); 62 | end 63 | displayCentroids = getNextBoolean(gd); 64 | displayFlag = getNextBoolean(gd); 65 | 66 | 67 | % run the kmeans 68 | [k, centroids] = kmeans(tab, nClasses); 69 | 70 | % create a new doc 71 | [frame2, doc2] = createTableFrame(frame.Gui, k); 72 | 73 | % optional processing of centroids 74 | if displayCentroids 75 | % create a new doc 76 | [frameC, docC] = createTableFrame(frame.Gui, centroids); %#ok 77 | historyString = sprintf('[%s,%s] = kmeans(%s, %d);\n', ... 78 | doc2.Tag, docC.Tag, doc.Tag, nClasses); 79 | else 80 | historyString = sprintf('%s = kmeans(%s, %d);\n', ... 81 | doc2.Tag, doc.Tag, nClasses); 82 | end 83 | addToHistory(frame2, historyString); 84 | 85 | 86 | if displayFlag && size(tab, 2) > 1 87 | figure; 88 | scatterGroup(tab(:,1), tab(:,2), k); 89 | end 90 | 91 | end 92 | 93 | end % end methods 94 | 95 | end % end classdef 96 | 97 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/CrossTable.m: -------------------------------------------------------------------------------- 1 | classdef CrossTable < imagem.gui.Action 2 | %CROSSTABLE Cross-Tabulation of two Tables. 3 | % 4 | % Class CrossTabled 5 | % 6 | % Example 7 | % CrossTabled 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-21, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = CrossTable(varargin) 27 | % Constructor for CrossTabled class 28 | obj = obj@imagem.gui.Action(); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | end % end methods 37 | 38 | end % end classdef 39 | 40 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/FoldTableToImage.m: -------------------------------------------------------------------------------- 1 | classdef FoldTableToImage < imagem.actions.CurrentTableAction 2 | %FOLDTABLETOIMAGE One-line description here, please. 3 | % 4 | % Class FoldTableToImage 5 | % 6 | % Example 7 | % FoldTableToImage 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-19, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = FoldTableToImage(varargin) 27 | % Constructor for FoldTableToImage class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function run(obj, frame) %#ok 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | tab = doc.Table; 41 | 42 | % table size 43 | nRows = size(tab, 1); 44 | nCols = size(tab, 2); 45 | 46 | % default options 47 | sizeX = nRows; 48 | sizeY = 1; 49 | if ~isempty(doc.ImageSize) 50 | sizeX = doc.ImageSize(1); 51 | sizeY = doc.ImageSize(2); 52 | end 53 | 54 | % open a dialog to choose slice index 55 | gd = imagem.gui.GenericDialog('Fold Table to image'); 56 | addNumericField(gd, 'Size X: ', sizeX, 0); 57 | addNumericField(gd, 'Size Y: ', sizeY, 0); 58 | setSize(gd, [200 150]); 59 | 60 | while true 61 | showDialog(gd); 62 | if wasCanceled(gd) 63 | return; 64 | end 65 | 66 | sizeX = getNextNumber(gd); 67 | sizeY = getNextNumber(gd); 68 | 69 | if sizeX * sizeY == nRows 70 | break; 71 | end 72 | msg = sprintf('Product of dimensions must match number of rows (%d)', nRows); 73 | hf = errordlg(msg, 'ImageM Error'); 74 | uiwait(hf); 75 | 76 | resetCounter(gd); 77 | end 78 | 79 | data = zeros(sizeX, sizeY, 1, nCols, 'like', tab.Data); 80 | data(:) = tab.Data(:); 81 | 82 | if nCols == 1 83 | img = Image('Data', data, 'type', 'intensity', 'channelNames', tab.ColNames(1)); 84 | else 85 | img = Image('Data', data, 'type', 'vector', 'channelNames', tab.ColNames); 86 | end 87 | 88 | createImageFrame(frame.Gui, img); 89 | end 90 | 91 | end % end methods 92 | 93 | end % end classdef 94 | 95 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+table/OpenDemoTable.m: -------------------------------------------------------------------------------- 1 | classdef OpenDemoTable < imagem.gui.Action 2 | % Open a new data table stored in a file. 3 | % 4 | % Class OpenDemoTable 5 | % 6 | % Example 7 | % OpenDemoTable 8 | % 9 | % See also 10 | % tblui.TableGuiAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2012 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Properties 21 | properties 22 | DemoFileName; 23 | end % end properties 24 | 25 | 26 | %% Constructor 27 | methods 28 | function obj = OpenDemoTable(fileName) 29 | % Constructor for OpenDemoTable class 30 | obj = obj@imagem.gui.Action(); 31 | obj.DemoFileName = fileName; 32 | end 33 | 34 | end % end constructors 35 | 36 | 37 | %% Methods 38 | methods 39 | function run(obj, frame) 40 | disp('Open demo table '); 41 | 42 | % get handle to parent GUI 43 | gui = frame.Gui; 44 | 45 | % read the demo image 46 | tab = Table.read(obj.DemoFileName); 47 | 48 | % add image to application, and create new display 49 | [frame2, doc2] = createTableFrame(gui, tab); 50 | 51 | % add history 52 | string = sprintf('%s = Table.read(''%s'');\n', ... 53 | doc2.Tag, obj.DemoFileName); 54 | addToHistory(frame2, string); 55 | end 56 | end % end methods 57 | 58 | end % end classdef 59 | 60 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/ImageSetDisplayRange.m: -------------------------------------------------------------------------------- 1 | classdef ImageSetDisplayRange < imagem.actions.CurrentImageAction 2 | % Change the values corresponding to black and white in display. 3 | % 4 | % Class ImageSetDisplayRangeAction 5 | % 6 | % Example 7 | % ImageSetDisplayRangeAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2016-01-06, using Matlab 8.6.0.267246 (R2015b) 16 | % Copyright 2016 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageSetDisplayRange() 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | 36 | % get handle to viewer figure, doc, and image 37 | img = currentImage(frame); 38 | 39 | if ~ismember(img.Type, {'grayscale', 'intensity', 'label'}) 40 | return; 41 | end 42 | 43 | % get extreme values for grayscale in image 44 | mini = min(img); 45 | maxi = max(img); 46 | 47 | % get actual value for grayscale range 48 | clim = get(frame.Handles.ImageAxis, 'CLim'); 49 | 50 | % define dialog options 51 | if isinteger(mini) 52 | prompt = {... 53 | sprintf('Min grayscale value (%d):', mini), ... 54 | sprintf('Max grayscale value (%d):', maxi)}; 55 | else 56 | prompt = {... 57 | sprintf('Min grayscale value (%f):', mini), ... 58 | sprintf('Max grayscale value (%f):', maxi)}; 59 | end 60 | title = 'Input for grayscale range'; 61 | nbLines = 1; 62 | default = {num2str(clim(1)), num2str(clim(2))}; 63 | 64 | % open the dialog 65 | answer = inputdlg(prompt, title, nbLines, default); 66 | 67 | % if user cancel, return 68 | if isempty(answer) 69 | return; 70 | end 71 | 72 | % convert input texts into numerical values 73 | mini = str2double(answer{1}); 74 | maxi = str2double(answer{2}); 75 | if isnan(mini) || isnan(maxi) 76 | return; 77 | end 78 | 79 | frame.DisplayRange = [mini maxi]; 80 | set(frame.Handles.ImageAxis, 'CLim', [mini maxi]); 81 | end 82 | end % end methods 83 | 84 | end % end classdef 85 | 86 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/PlotLabelMapCurvesFromTable.m: -------------------------------------------------------------------------------- 1 | classdef PlotLabelMapCurvesFromTable < imagem.actions.LabelImageAction 2 | % One-line description here, please. 3 | % 4 | % Class PlotLabelMapCurvesFromTable 5 | % 6 | % Example 7 | % PlotLabelMapCurvesFromTable 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-09-18, using Matlab 9.6.0.1072779 (R2019a) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PlotLabelMapCurvesFromTable(viewer) 27 | end 28 | 29 | end % end constructors 30 | 31 | 32 | %% Methods 33 | methods 34 | function run(obj, frame) %#ok 35 | disp('plot label map curves from data table'); 36 | 37 | [fileName, pathName] = uigetfile( ... 38 | {'*.txt;*.csv;*.div', ... 39 | 'All Data Table Files (*.txt, *.csv, *.div)'; ... 40 | '*.txt', 'TEXT Files (*.txt)'; ... 41 | '*.csv', 'CSV Files (*.csv)'; ... 42 | '*.div', 'DIV Files (*.div)'; ... 43 | '*.*', 'All Files (*.*)'}, ... 44 | 'Choose a data table:'); 45 | 46 | if isequal(fileName,0) || isequal(pathName,0) 47 | return; 48 | end 49 | 50 | % read the selected file 51 | tablePath = fullfile(pathName, fileName); 52 | tab = Table.read(tablePath); 53 | 54 | tool = imagem.tools.PlotClickedLabelCurve(frame, tab); 55 | frame.CurrentTool = tool; 56 | end 57 | end % end methods 58 | 59 | end % end classdef 60 | 61 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/PrintImageDocList.m: -------------------------------------------------------------------------------- 1 | classdef PrintImageDocListAction < imagem.gui.ImagemAction 2 | % Print the list of open documents. 3 | % 4 | % output = PrintImageDocListAction(input) 5 | % 6 | % Example 7 | % PrintImageDocListAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-07, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = PrintImageDocListAction(viewer, varargin) 20 | % calls the parent constructor 21 | obj = obj@imagem.gui.ImagemAction(viewer, 'printImageDocList'); 22 | end 23 | end 24 | 25 | methods 26 | function actionPerformed(obj, src, event) %#ok 27 | disp('print image list'); 28 | 29 | % get handle to viewer figure, and current doc 30 | app = obj.Viewer.Gui.App; 31 | 32 | docList = getDocuments(app); 33 | for i = 1:length(docList) 34 | doc = docList{i}; 35 | if ~isempty(doc.Image) 36 | disp(doc.Image.Name); 37 | end 38 | end 39 | end 40 | end 41 | 42 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/SetBackgroundColor.m: -------------------------------------------------------------------------------- 1 | classdef SetBackgroundColor < imagem.actions.CurrentImageAction 2 | % Set the color associated to background pixels/voxels of an image. 3 | % 4 | % Class SetBackgroundColor 5 | % 6 | % Example 7 | % SetBackgroundColor 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-07-31, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = SetBackgroundColor(varargin) 27 | % Constructor for SetBackgroundColor class. 28 | obj = obj@imagem.actions.CurrentImageAction(); 29 | end 30 | end % end constructors 31 | 32 | 33 | %% Methods 34 | methods 35 | function run(obj, frame) %#ok 36 | disp('Change Image Background Color'); 37 | 38 | % get handle to current doc 39 | doc = frame.Doc; 40 | 41 | % get current BG color, and convert to 0-255 scalar values. 42 | bgColor = doc.BackgroundColor; 43 | bgR8 = bgColor(1) * 255; 44 | bgG8 = bgColor(2) * 255; 45 | bgB8 = bgColor(3) * 255; 46 | 47 | gd = imagem.gui.GenericDialog('Set Background Color'); 48 | addNumericField(gd, 'Red: ', bgR8, 0); 49 | addNumericField(gd, 'Green: ', bgG8, 0); 50 | addNumericField(gd, 'Blue: ', bgB8, 0); 51 | 52 | % displays the dialog, and waits for user 53 | showDialog(gd); 54 | % check if ok or cancel was clicked 55 | if wasCanceled(gd) 56 | return; 57 | end 58 | 59 | % gets the user inputs 60 | bgR8 = getNextNumber(gd); 61 | bgG8 = getNextNumber(gd); 62 | bgB8 = getNextNumber(gd); 63 | bgColor = max(min([bgR8 bgG8 bgB8], 255), 0) / 255; 64 | 65 | doc.BackgroundColor = bgColor; 66 | doc.Modified = true; 67 | 68 | updateDisplay(frame); 69 | end 70 | 71 | function b = isActivable(obj, frame) %#ok 72 | % Check if current doc contains either a label or intensity image. 73 | doc = frame.Doc; 74 | b = ~isempty(doc) && ~isempty(doc.Image); 75 | if b 76 | img = doc.Image; 77 | b = isLabelImage(img) || isIntensityImage(img); 78 | end 79 | end 80 | end % end methods 81 | 82 | end % end classdef 83 | 84 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/SetCurrentZoomLevel.m: -------------------------------------------------------------------------------- 1 | classdef SetCurrentZoomLevel < imagem.actions.CurrentImageAction 2 | % Set zoom of current image viewer to a chosen value. 3 | % 4 | % output = ZoomOneAction(input) 5 | % 6 | % Example 7 | % ZoomOneAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | Factor; 20 | end 21 | 22 | methods 23 | function obj = SetCurrentZoomLevel(factor) 24 | % calls the parent constructor 25 | obj.Factor = factor; 26 | end 27 | end 28 | 29 | methods 30 | function run(obj, frame) %#ok 31 | 32 | % set up new zoom value 33 | setCurrentZoomLevel(frame, obj.Factor); 34 | 35 | % update display 36 | updateTitle(frame); 37 | end 38 | end 39 | 40 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/SetZoomMode.m: -------------------------------------------------------------------------------- 1 | classdef SetZoomMode < imagem.actions.CurrentImageAction 2 | % Set the zoom mode for current frame (fixed or adjust) 3 | % 4 | % output = ZoomSetModeAction(input) 5 | % 6 | % Example 7 | % ZoomSetModeAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | ZoomMode = 'adjust'; 20 | 21 | MenuItem; 22 | ActionGroup; 23 | end 24 | 25 | methods 26 | function obj = SetZoomMode(mode) 27 | obj.ZoomMode = mode; 28 | end 29 | end 30 | 31 | methods 32 | function run(obj, frame) %#ok 33 | 34 | % set up new zoom value 35 | setZoomMode(frame, obj.ZoomMode); 36 | 37 | if ~isempty(obj.ActionGroup) 38 | for iAction = 1:length(obj.ActionGroup) 39 | action = obj.ActionGroup(iAction); 40 | uncheckMenuItem(action); 41 | end 42 | end 43 | 44 | if ~isempty(obj.MenuItem) 45 | set(obj.MenuItem, 'Checked', 'On'); 46 | end 47 | end 48 | 49 | 50 | function setMenuItem(obj, item) 51 | obj.MenuItem = item; 52 | end 53 | 54 | function setActionGroup(obj, group) 55 | obj.ActionGroup = group; 56 | end 57 | 58 | function uncheckMenuItem(obj) 59 | if ~isempty(obj.MenuItem) 60 | set(obj.MenuItem, 'Checked', 'Off'); 61 | end 62 | end 63 | end 64 | 65 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/ZoomBestFit.m: -------------------------------------------------------------------------------- 1 | classdef ZoomBestFit < imagem.actions.CurrentImageAction 2 | % Set zoom of current image viewer to the best possible one. 3 | % 4 | % output = ZoomBestAction(input) 5 | % 6 | % Example 7 | % ZoomBestAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ZoomBestFit() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % set up new zoom value 27 | zoom = findBestZoom(frame); 28 | setCurrentZoomLevel(frame, zoom); 29 | 30 | % update display 31 | updateTitle(frame); 32 | end 33 | end 34 | 35 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/ZoomIn.m: -------------------------------------------------------------------------------- 1 | classdef ZoomIn < imagem.actions.CurrentImageAction 2 | % Zoom in the current figure. 3 | % 4 | % output = ZoomInAction(input) 5 | % 6 | % Example 7 | % ZoomInAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ZoomIn() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % set up new zoom value 27 | zoom = currentZoomLevel(frame); 28 | setCurrentZoomLevel(frame, zoom * 2); 29 | 30 | % update display 31 | updateTitle(frame); 32 | end 33 | end 34 | 35 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/ZoomOne.m: -------------------------------------------------------------------------------- 1 | classdef ZoomOne < imagem.actions.CurrentImageAction 2 | % Set zoom of current image viewer to 1. 3 | % 4 | % output = ZoomOneAction(input) 5 | % 6 | % Example 7 | % ZoomOneAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ZoomOne() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % set up new zoom value 27 | setCurrentZoomLevel(frame, 1); 28 | 29 | % update display 30 | updateTitle(frame); 31 | end 32 | end 33 | 34 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/+view/ZoomOut.m: -------------------------------------------------------------------------------- 1 | classdef ZoomOut < imagem.actions.CurrentImageAction 2 | % Zoom out the current figure. 3 | % 4 | % output = ZoomOutAction(input) 5 | % 6 | % Example 7 | % ZoomOutAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-12-02, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = ZoomOut() 20 | end 21 | end 22 | 23 | methods 24 | function run(obj, frame) %#ok 25 | 26 | % set up new zoom value 27 | zoom = currentZoomLevel(frame); 28 | setCurrentZoomLevel(frame, zoom / 2); 29 | 30 | % update display 31 | updateTitle(frame); 32 | end 33 | end 34 | 35 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/BinaryImageAction.m: -------------------------------------------------------------------------------- 1 | classdef BinaryImageAction < imagem.actions.CurrentImageAction 2 | % Superclass for actions that require a binary image. 3 | % 4 | % output = BinaryImageAction(input) 5 | % 6 | % Example 7 | % BinaryImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = BinaryImageAction(varargin) 20 | % calls the parent constructor 21 | obj = obj@imagem.actions.CurrentImageAction(varargin{:}); 22 | end 23 | end 24 | 25 | methods 26 | function b = isActivable(obj, frame) 27 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 28 | if b 29 | b = isBinaryImage(currentImage(frame)); 30 | end 31 | end 32 | end 33 | 34 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/CurrentDocAction.m: -------------------------------------------------------------------------------- 1 | classdef CurrentDocAction < imagem.gui.Action 2 | % Superclass for actions that require a current document. 3 | % 4 | % output = CurrentImageAction(input) 5 | % 6 | % Example 7 | % CurrentImageAction 8 | % 9 | % See also 10 | % ImgemAction, CurrentImageAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Constructors 21 | methods 22 | function obj = CurrentDocAction() 23 | end 24 | end 25 | 26 | %% Specialisation of ImageMAction superclass 27 | methods 28 | function b = isActivable(obj, frame) %#ok 29 | b = ~isempty(frame.Doc); 30 | end 31 | end 32 | 33 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/CurrentImageAction.m: -------------------------------------------------------------------------------- 1 | classdef CurrentImageAction < imagem.actions.CurrentDocAction 2 | % Superclass for actions that require a current image. 3 | % 4 | % output = CurrentImageAction(input) 5 | % 6 | % Example 7 | % CurrentImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Constructors 20 | methods 21 | function obj = CurrentImageAction() 22 | end 23 | end 24 | 25 | 26 | %% New methods 27 | methods 28 | end 29 | 30 | 31 | %% Specialisation of ImageMAction superclass 32 | methods 33 | function b = isActivable(obj, frame) 34 | b = isActivable@imagem.actions.CurrentDocAction(obj, frame); 35 | if b 36 | b = isa(frame.Doc, 'imagem.app.ImageDoc'); 37 | end 38 | if b 39 | b = ~isempty(currentImage(frame)); 40 | end 41 | end 42 | end 43 | 44 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/CurrentTableAction.m: -------------------------------------------------------------------------------- 1 | classdef CurrentTableAction < imagem.gui.Action 2 | % Superclass for actions that require a current table. 3 | % 4 | % output = CurrentTableAction(input) 5 | % 6 | % Example 7 | % CurrentImageAction 8 | % 9 | % See also 10 | % ImgemAction, CurrentImageAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Constructors 21 | methods 22 | function obj = CurrentTableAction() 23 | end 24 | end 25 | 26 | %% Specialisation of ImageMAction superclass 27 | methods 28 | function b = isActivable(obj, frame) %#ok 29 | b = ~isempty(frame.Doc); 30 | if b 31 | b = isa(frame.Doc, 'imagem.app.TableDoc'); 32 | end 33 | end 34 | end 35 | 36 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/GenericAction.m: -------------------------------------------------------------------------------- 1 | classdef GenericAction < imagem.gui.Action 2 | % A generic class for managing actions with simple commands. 3 | % 4 | % action = GenericAction(VIEWER, COMMAND_NAME, FHANDLE) 5 | % 6 | % Example 7 | % GenericAction 8 | % 9 | % See also 10 | % 11 | 12 | 13 | properties 14 | FunctionHandle; 15 | end 16 | 17 | methods 18 | function obj = GenericAction(fhandle) 19 | % calls the parent constructor 20 | obj.FunctionHandle = fhandle; 21 | end 22 | end 23 | 24 | methods 25 | function run(obj, frame) 26 | % simply calls the stored handle 27 | obj.FunctionHandle(frame); 28 | end 29 | end 30 | 31 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/Image3DAction.m: -------------------------------------------------------------------------------- 1 | classdef Image3DAction < imagem.actions.CurrentImageAction 2 | % Superclass for actions that require a 3D image. 3 | % 4 | % Class Image3DAction 5 | % 6 | % Example 7 | % Image3DAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = Image3DAction(varargin) 27 | % Constructor for Image3DAction class 28 | obj = obj@imagem.actions.CurrentImageAction(varargin{:}); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function b = isActivable(obj, frame) 37 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 38 | if b 39 | b = is3dImage(currentImage(frame)); 40 | end 41 | end 42 | end % end methods 43 | 44 | end % end classdef 45 | 46 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/LabelImageAction.m: -------------------------------------------------------------------------------- 1 | classdef LabelImageAction < imagem.actions.ScalarImageAction 2 | % Superclass for actions that require a label image. 3 | % 4 | % output = LabelImageAction(input) 5 | % 6 | % Example 7 | % ScalarImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-30, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function obj = LabelImageAction(varargin) 20 | % calls the parent constructor 21 | obj = obj@imagem.actions.ScalarImageAction(varargin{:}); 22 | end 23 | end 24 | 25 | methods 26 | function b = isActivable(obj, frame) 27 | b = isActivable@imagem.actions.ScalarImageAction(obj, frame); 28 | if b 29 | b = isLabelImage(currentImage(frame)); 30 | end 31 | end 32 | end 33 | 34 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/PrintHello.m: -------------------------------------------------------------------------------- 1 | classdef PrintHello < imagem.gui.Action 2 | % Simple demo action. 3 | % 4 | % Simple class for demonstrating the use of action classes. 5 | % 6 | % Example 7 | % SayHelloAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | methods 19 | function this = PrintHello() 20 | end 21 | end 22 | 23 | methods 24 | function run(this, frame) %#ok 25 | disp('Hello!'); 26 | end 27 | end 28 | 29 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/ScalarImageAction.m: -------------------------------------------------------------------------------- 1 | classdef ScalarImageAction < imagem.actions.CurrentImageAction 2 | % Superclass for actions that require a scalar image. 3 | % 4 | % output = ScalarImageAction(input) 5 | % 6 | % Example 7 | % ScalarImageAction 8 | % 9 | % See also 10 | % CurrentImageAction, BinaryImageAction 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | methods 20 | function this = ScalarImageAction(varargin) 21 | % calls the parent constructor 22 | this = this@imagem.actions.CurrentImageAction(varargin{:}); 23 | end 24 | end 25 | 26 | methods 27 | function b = isActivable(obj, frame) 28 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 29 | b = b && isScalarImage(currentImage(frame)); 30 | end 31 | end 32 | 33 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/SelectTool.m: -------------------------------------------------------------------------------- 1 | classdef SelectTool < imagem.gui.Action 2 | % Changes the selected tool. 3 | % 4 | % output = SelectToolAction(input) 5 | % 6 | % Example 7 | % SelectToolAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | properties 19 | % A function handle to the tool constructor. 20 | BuildFunction; 21 | 22 | % An optional function used to decide whether the action can be used. 23 | IsActivableFunction; 24 | end 25 | 26 | methods 27 | function obj = SelectTool(buildFn, varargin) 28 | obj.BuildFunction = buildFn; 29 | 30 | obj.IsActivableFunction = @(x) true; 31 | if ~isempty(varargin) 32 | var1 = varargin{1}; 33 | if isa(var1, 'function_handle') 34 | obj.IsActivableFunction = var1; 35 | end 36 | end 37 | end 38 | end 39 | 40 | methods 41 | function run(obj, frame) 42 | tool = obj.BuildFunction(frame); 43 | frame.CurrentTool = tool; 44 | end 45 | end 46 | 47 | methods 48 | function b = isActivable(obj, frame) 49 | b = obj.IsActivableFunction(frame); 50 | end 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/TimeLapseImageAction.m: -------------------------------------------------------------------------------- 1 | classdef TimeLapseImageAction < imagem.actions.CurrentImageAction 2 | % Superclass for actions that require a time-lapse image. 3 | % 4 | % Class TimeLapseImageAction 5 | % 6 | % Example 7 | % TimeLapseImageAction 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-02-20, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = TimeLapseImageAction(varargin) 27 | % Constructor for TimeLapseImageAction class 28 | obj = obj@imagem.actions.CurrentImageAction(varargin{:}); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function b = isActivable(obj, frame) 37 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 38 | if b 39 | b = isTimeLapseImage(currentImage(frame)); 40 | end 41 | end 42 | end % end methods 43 | 44 | end % end classdef 45 | 46 | -------------------------------------------------------------------------------- /ImageM/+imagem/+actions/VectorImageAction.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageAction < imagem.actions.CurrentImageAction 2 | %Superclass for actions that require a vector image as current image. 3 | % 4 | % output = VectorImageAction(input) 5 | % 6 | % Example 7 | % VectorImageAction 8 | % 9 | % See also 10 | % 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2012-03-13, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | methods 20 | function this = VectorImageAction(varargin) 21 | % calls the parent constructor 22 | this = this@imagem.actions.CurrentImageAction(varargin{:}); 23 | end 24 | end 25 | 26 | methods 27 | function b = isActivable(obj, frame) 28 | b = isActivable@imagem.actions.CurrentImageAction(obj, frame); 29 | b = b && isVectorImage(frame.Doc.Image); 30 | end 31 | end 32 | 33 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+app/ImagemDoc.m: -------------------------------------------------------------------------------- 1 | classdef ImagemDoc < handle 2 | % ImageM Document class that contains one image and the associated data. 3 | % 4 | % Class ImagemDoc 5 | % 6 | % Example 7 | % ImagemDoc 8 | % 9 | % See also 10 | % ImageDoc, TableDoc 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2011-10-22, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | % The short name used to identify document on command-line arguments. 22 | % Examples of common tags: img01, tab02, lbl03... 23 | Tag; 24 | 25 | % A flag of modification. 26 | Modified = false; 27 | 28 | % A set of views attached to this doc. Can be image viewer, profiles... 29 | Views = {}; 30 | 31 | end % end properties 32 | 33 | 34 | %% Constructor 35 | methods 36 | function obj = ImagemDoc() 37 | % Constructor for ImagemDoc class. 38 | end 39 | 40 | end % end constructors 41 | 42 | 43 | %% Methods for view management 44 | methods 45 | function addView(obj, v) 46 | obj.Views = [obj.Views {v}]; 47 | end 48 | 49 | function removeView(obj, v) 50 | ind = -1; 51 | for i = 1:length(obj.Views) 52 | if obj.Views{i} == v 53 | ind = i; 54 | break; 55 | end 56 | end 57 | 58 | if ind == -1 59 | error('could not find the view'); 60 | end 61 | 62 | obj.Views(ind) = []; 63 | end 64 | 65 | function v = getViews(obj) 66 | v = obj.Views; 67 | end 68 | 69 | end % end methods 70 | 71 | end % end classdef 72 | 73 | -------------------------------------------------------------------------------- /ImageM/+imagem/+app/TableDoc.m: -------------------------------------------------------------------------------- 1 | classdef TableDoc < imagem.app.ImagemDoc 2 | %TABLEDOC Enapsulates a data Table, and data for GUI interaction. 3 | % 4 | % Class TableDoc 5 | % 6 | % Example 7 | % TableDoc 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2012-03-26, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2012 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | % The data table that stores the data. 22 | Table; 23 | 24 | % The size of the image that was used to generate this table, if relevant. 25 | ImageSize = []; 26 | 27 | end % end properties 28 | 29 | 30 | %% Constructor 31 | methods 32 | function obj = TableDoc(table, varargin) 33 | % Constructor for TableDoc class 34 | % 35 | % Usage: 36 | % DOC = imagem.app.TableDoc(TAB) 37 | % DOC = imagem.app.TableDoc(TAB, PARENTDOC) 38 | % 39 | obj.Table = table; 40 | 41 | if ~isempty(varargin) 42 | if isa(varargin{1}, 'imagem.app.TableDoc') 43 | refDoc = varargin{1}; 44 | obj.ImageSize = refDoc.ImageSize; 45 | else 46 | error('Unable to process additional arguments'); 47 | end 48 | end 49 | 50 | end 51 | 52 | end % end constructors 53 | 54 | 55 | %% Methods 56 | methods 57 | end % end methods 58 | 59 | end % end classdef 60 | 61 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+events/ImageDisplayListener.m: -------------------------------------------------------------------------------- 1 | classdef ImageDisplayListener < handle 2 | % Listener for changes of image display. 3 | % 4 | % Class ImageDisplayListener 5 | % 6 | % Example 7 | % ImageDisplayListener 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-18, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = ImageDisplayListener(varargin) 27 | % Constructor for ImageDislayListener class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | onDisplayRangeChanged(obj, source, event) 37 | onCurrentSliceChanged(obj, source, event) 38 | onCurrentChannelChanged(obj, source, event) 39 | end % end methods 40 | 41 | end % end classdef 42 | 43 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+events/MouseListener.m: -------------------------------------------------------------------------------- 1 | classdef MouseListener < handle 2 | % Listener for mouse events. 3 | % 4 | % Class MouseListener 5 | % 6 | % Example 7 | % MouseListener 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = MouseListener(varargin) 27 | % Constructor for MouseListener class 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods (Abstract) 36 | onMouseButtonPressed(obj, source, event) 37 | onMouseButtonReleased(obj, source, event) 38 | onMouseMoved(obj, source, event) 39 | end % end methods 40 | 41 | end % end classdef 42 | 43 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+icons/lineSegment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattools/ImageM/58c455f5c0c5d8f48bf9094cf4d2d4bdce9f4598/ImageM/+imagem/+gui/+icons/lineSegment.png -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+icons/points.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattools/ImageM/58c455f5c0c5d8f48bf9094cf4d2d4bdce9f4598/ImageM/+imagem/+gui/+icons/points.png -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+icons/polygon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattools/ImageM/58c455f5c0c5d8f48bf9094cf4d2d4bdce9f4598/ImageM/+imagem/+gui/+icons/polygon.png -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/+icons/polyline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattools/ImageM/58c455f5c0c5d8f48bf9094cf4d2d4bdce9f4598/ImageM/+imagem/+gui/+icons/polyline.png -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/Action.m: -------------------------------------------------------------------------------- 1 | classdef Action < handle 2 | % Base class for ImageM action classes. 3 | % 4 | % output = Action(input) 5 | % 6 | % Example 7 | % Action 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2019-09-18, using Matlab 9.6.0.1072779 (R2019a) 16 | % Copyright 2019 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Methods to overload 20 | methods (Abstract) 21 | run(obj, frame) 22 | end 23 | 24 | %% Methods that can be overloaded 25 | methods 26 | function b = isActivable(obj, viewer) 27 | b = true; 28 | end 29 | end 30 | 31 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/GuiOptions.m: -------------------------------------------------------------------------------- 1 | classdef GuiOptions < handle 2 | %Global options for creating GUIs. 3 | % 4 | % Class GuiOptions 5 | % 6 | % Example 7 | % GuiOptions 8 | % 9 | % See also 10 | % ImagemGUI 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-19, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | TextOptions = {'FontSize', 14}; 22 | 23 | DlgListSize = [180 220]; 24 | 25 | end % end properties 26 | 27 | 28 | %% Constructor 29 | methods 30 | function obj = GuiOptions() 31 | % Constructor for GuiOptions class 32 | 33 | end 34 | 35 | end % end constructors 36 | 37 | 38 | %% Methods 39 | methods 40 | end % end methods 41 | 42 | end % end classdef 43 | 44 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/ImagemAction.m: -------------------------------------------------------------------------------- 1 | classdef ImagemAction < handle 2 | % Base class for ImageM action classes. 3 | % 4 | % output = ImagemAction(input) 5 | % 6 | % Example 7 | % ImagemAction 8 | % 9 | % See also 10 | % imagem.gui.ImagemTool 11 | % 12 | 13 | % ------ 14 | % Author: David Legland 15 | % e-mail: david.legland@inra.fr 16 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 17 | % Copyright 2011 INRA - Cepia Software Platform. 18 | 19 | 20 | %% Properties definition 21 | 22 | properties 23 | % the parent GUI, that can be ImageViewer, TableViewer... 24 | Viewer; 25 | 26 | % the name of obj action, that should be unique for all actions 27 | Name; 28 | end 29 | 30 | 31 | %% Constructor 32 | 33 | methods 34 | function obj = ImagemAction(viewer, name) 35 | obj.Viewer = viewer; 36 | obj.Name = name; 37 | end 38 | end 39 | 40 | 41 | %% Methods to be overloaded 42 | 43 | methods (Abstract) 44 | actionPerformed(obj, src, event) 45 | end 46 | 47 | methods 48 | function b = isActivable(obj) %#ok 49 | b = true; 50 | end 51 | end 52 | 53 | 54 | %% Utility methods 55 | % 56 | % Some of them are simply shortcuts that dispatch the processing to other 57 | % classes. 58 | 59 | methods 60 | function varargout = addImageDocument(obj, image, varargin) 61 | % Create a new frame for the image based on the current viewer. 62 | if nargin <= 1 63 | doc = addImageDocument(obj.Viewer.Gui, image, varargin{:}); 64 | varargout = {doc}; 65 | else 66 | [doc, viewer] = addImageDocument(obj.Viewer.Gui, image, varargin{:}); 67 | varargout = {doc, viewer}; 68 | end 69 | end 70 | 71 | function addToHistory(obj, string) 72 | addToHistory(obj.Viewer.Gui.App, string); 73 | end 74 | end 75 | 76 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/ImagemFrame.m: -------------------------------------------------------------------------------- 1 | classdef ImagemFrame < handle 2 | % Base class for all figure widgets managed by ImageM application. 3 | % 4 | % Class ImagemFrame 5 | % 6 | % Example 7 | % ImagemFrame 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-11-15, using Matlab 9.7.0.1190202 (R2019b) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | % Reference to the main GUI. 22 | Gui; 23 | 24 | % List of handles to the various gui items. 25 | Handles; 26 | 27 | end % end properties 28 | 29 | 30 | %% Constructor 31 | methods 32 | function obj = ImagemFrame(gui) 33 | % Constructor for ImagemFrame class 34 | % 35 | % Usage: 36 | % OBJ = ImagemFrame(GUI); 37 | % where GUI is an instance of ImagemGUI. 38 | 39 | obj.Gui = gui; 40 | obj.Handles = struct(); 41 | end 42 | 43 | end % end constructors 44 | 45 | 46 | %% Methods 47 | methods 48 | function [frame, doc] = createImageFrame(obj, image, varargin) 49 | % Create a new frame for the image based on the current frame. 50 | [frame, doc] = createImageFrame(obj.Gui, image, varargin{:}); 51 | if isa(obj, 'imagem.gui.ImageViewer') && ~isempty(obj.Doc) 52 | doc.ChannelDisplayType = obj.Doc.ChannelDisplayType; 53 | end 54 | end 55 | 56 | function [doc, viewer] = addImageDocument(obj, image, varargin) 57 | % Create a new frame for the image based on the current frame. 58 | [viewer, doc] = createImageFrame(obj.Gui, image, varargin{:}); 59 | if isa(obj, 'imagem.gui.ImageViewer') && ~isempty(obj.Doc) 60 | doc.ChannelDisplayType = obj.Doc.ChannelDisplayType; 61 | end 62 | end 63 | 64 | function addToHistory(obj, string) 65 | % Simple wrapper to the function in App class. 66 | % 67 | % See Also 68 | % imagem.app.App.addToHistory 69 | 70 | addToHistory(obj.Gui.App, string); 71 | end 72 | end % end methods 73 | 74 | end % end classdef 75 | 76 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/ImagemTool.m: -------------------------------------------------------------------------------- 1 | classdef ImagemTool < imagem.gui.events.MouseListener 2 | % Base class for interactive (mouse management) tools. 3 | % 4 | % ImagemTool is an abstract class that serves as basis for developping 5 | % more sophisticated classes. It encapsulates functions for interpreting 6 | % mouse button events and mouse motion events. 7 | % 8 | % An ImageM Tool depends on a display, usually an ImageViewer. 9 | % 10 | % Most ImageM Tool are also defined by their current "state". The state 11 | % will change the way the mouse events are processed. 12 | % 13 | % 14 | 15 | % ------ 16 | % Author: David Legland 17 | % e-mail: david.legland@inra.fr 18 | % Created: 2011-11-13, using Matlab 7.9.0.529 (R2009b) 19 | % Copyright 2011 INRA - Cepia Software Platform. 20 | 21 | %% Properties 22 | properties 23 | % the parent GUI, that can be ImageDisplay, TableDisplay... 24 | Viewer; 25 | 26 | % the name of obj tool, that should be unique for all actions 27 | Name; 28 | end 29 | 30 | %% Constructor 31 | methods 32 | function obj = ImagemTool(viewer, name) 33 | % Creates a new tool using parent viewer and a name 34 | obj.Viewer = viewer; 35 | obj.Name = name; 36 | end % constructor 37 | 38 | end % construction function 39 | 40 | %% General methods 41 | methods 42 | function select(obj) %#ok<*MANU> 43 | end 44 | 45 | function deselect(obj) 46 | end 47 | 48 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 49 | end 50 | 51 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 52 | end 53 | 54 | function onMouseMoved(obj, hObject, eventdata) %#ok 55 | end 56 | 57 | end % general methods 58 | 59 | methods 60 | function b = isActivable(obj) 61 | doc = currentDoc(obj); 62 | b = ~isempty(doc) && ~isempty(doc.Image); 63 | end 64 | end 65 | 66 | 67 | %% Utility methods 68 | methods 69 | function doc = currentDoc(obj) 70 | doc = obj.Viewer.Doc; 71 | end 72 | end 73 | 74 | end % classdef 75 | -------------------------------------------------------------------------------- /ImageM/+imagem/+gui/Tool.m: -------------------------------------------------------------------------------- 1 | classdef Tool < imagem.gui.events.MouseListener 2 | % Base class for interactive (mouse management) tools. 3 | % 4 | % ImagemTool is an abstract class that serves as basis for developping 5 | % more sophisticated classes. It encapsulates functions for interpreting 6 | % mouse button events and mouse motion events. 7 | % 8 | % An ImageM Tool depends on a display, usually an ImageViewer. 9 | % 10 | % Most ImageM Tool are also defined by their current "state". The state 11 | % will change the way the mouse events are processed. 12 | % 13 | % 14 | 15 | % ------ 16 | % Author: David Legland 17 | % e-mail: david.legland@inra.fr 18 | % Created: 2011-11-13, using Matlab 7.9.0.529 (R2009b) 19 | % Copyright 2011 INRA - Cepia Software Platform. 20 | 21 | %% Properties 22 | properties 23 | % the parent GUI, that can be ImageViewer or other type of frame 24 | Viewer; 25 | 26 | % the name of obj tool, that should be unique for all actions 27 | Name; 28 | end 29 | 30 | %% Constructor 31 | methods 32 | function obj = Tool(viewer, name) 33 | % Creates a new tool using parent viewer and a name 34 | obj.Viewer = viewer; 35 | obj.Name = name; 36 | end % constructor 37 | 38 | end % construction function 39 | 40 | %% General methods 41 | methods 42 | function select(obj) %#ok<*MANU> 43 | end 44 | 45 | function deselect(obj) 46 | end 47 | 48 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 49 | end 50 | 51 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 52 | end 53 | 54 | function onMouseMoved(obj, hObject, eventdata) %#ok 55 | end 56 | 57 | end % general methods 58 | 59 | methods 60 | function b = isActivable(obj) 61 | doc = currentDoc(obj.Viewer); 62 | b = ~isempty(doc) && ~isempty(doc.Image); 63 | end 64 | end 65 | 66 | 67 | %% Utility methods 68 | methods 69 | function doc = currentDoc(obj) 70 | doc = obj.Viewer.Doc; 71 | end 72 | end 73 | 74 | end % classdef 75 | -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/FloodFillTool.m: -------------------------------------------------------------------------------- 1 | classdef FloodFillTool < imagem.gui.Tool 2 | % Set pixel color to white 3 | % 4 | % output = FloodFillToolTool(input) 5 | % 6 | % Example 7 | % FloodFillToolTool 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-21, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | %% Properties 19 | properties 20 | ButtonPressed = false; 21 | end 22 | 23 | %% Constructor 24 | methods 25 | function obj = FloodFillTool(viewer, varargin) 26 | % Creates a new tool using parent gui and a name 27 | obj = obj@imagem.gui.Tool(viewer, 'floofill'); 28 | end % constructor 29 | 30 | end % construction function 31 | 32 | %% General methods 33 | methods 34 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 35 | processCurrentPosition(obj); 36 | obj.ButtonPressed = true; 37 | end 38 | 39 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 40 | obj.ButtonPressed = false; 41 | end 42 | 43 | function onMouseMoved(obj, hObject, eventdata) %#ok 44 | if ~obj.ButtonPressed 45 | return; 46 | end 47 | processCurrentPosition(obj); 48 | end 49 | 50 | function processCurrentPosition(obj) 51 | doc = currentDoc(obj); 52 | img = doc.Image; 53 | 54 | if ~isScalarImage(img) 55 | return; 56 | end 57 | 58 | point = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint'); 59 | coord = round(pointToIndex(obj, point(1, 1:2))); 60 | 61 | % control on bounds of image 62 | if any(coord < 1) || any(coord > size(img, [1 2])) 63 | return; 64 | end 65 | 66 | % apply floodfill and update current image 67 | res = floodFill(img, coord, obj.Viewer.Gui.App.BrushValue); 68 | img.Data = res.Data; 69 | 70 | doc.Modified = true; 71 | updateDisplay(obj.Viewer); 72 | end 73 | 74 | function index = pointToIndex(obj, point) 75 | % Converts coordinates of a point in physical dimension to image index 76 | % First element is column index, second element is row index, both are 77 | % given in floating point and no rounding is performed. 78 | doc = currentDoc(obj); 79 | img = doc.Image; 80 | spacing = img.Spacing(1:2); 81 | origin = img.Origin(1:2); 82 | index = (point - origin) ./ spacing + 1; 83 | end 84 | 85 | end % methods 86 | 87 | end % classdef -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/PickValueOrColor.m: -------------------------------------------------------------------------------- 1 | classdef PickValueOrColor < imagem.gui.Tool 2 | % Pick the new value or color for brush or flood-fill. 3 | % 4 | % Class PickValueOrColor 5 | % 6 | % Example 7 | % PickValueOrColor 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2020-02-11, using Matlab 9.7.0.1247435 (R2019b) Update 2 16 | % Copyright 2020 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = PickValueOrColor(parent, varargin) 27 | % Constructor for PickValueOrColor class 28 | obj = obj@imagem.gui.Tool(parent, 'pickValueOrColor'); 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods 36 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 37 | doc = currentDoc(obj); 38 | img = doc.Image; 39 | 40 | if ~isScalarImage(img) 41 | return; 42 | end 43 | 44 | point = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint'); 45 | coord = round(pointToIndex(obj, point(1, 1:2))); 46 | 47 | pos = [num2cell(coord), {1, ':'}]; 48 | if isa(obj.Viewer, 'Image3DSliceViewer') 49 | pos{3} = obj.Viewer.SliceIndex; 50 | end 51 | 52 | if isScalarImage(img) 53 | obj.Viewer.Gui.App.BrushValue = img.Data(pos{:}); 54 | else 55 | values = img.Data(pos{:}); 56 | obj.Viewer.Gui.App.BrushColor = values(:)'; 57 | end 58 | 59 | end 60 | 61 | function index = pointToIndex(obj, point) 62 | % Converts coordinates of a point in physical dimension to image index 63 | % First element is column index, second element is row index, both are 64 | % given in floating point and no rounding is performed. 65 | doc = currentDoc(obj); 66 | img = doc.Image; 67 | spacing = img.Spacing(1:2); 68 | origin = img.Origin(1:2); 69 | index = (point - origin) ./ spacing + 1; 70 | end 71 | 72 | end % end methods 73 | 74 | end % end classdef 75 | 76 | -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/PlotClickedLabelCurve.m: -------------------------------------------------------------------------------- 1 | classdef PlotClickedLabelCurve < imagem.gui.Tool 2 | %PLOTCLICKEDLABELCURVE One-line description here, please. 3 | % 4 | % Class PlotClickedLabelCurve 5 | % 6 | % Example 7 | % PlotClickedLabelCurve 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2019-09-18, using Matlab 9.6.0.1072779 (R2019a) 16 | % Copyright 2019 INRA - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | Table; 22 | 23 | XData; 24 | 25 | Handles; 26 | 27 | end % end properties 28 | 29 | 30 | %% Constructor 31 | methods 32 | function obj = PlotClickedLabelCurve(viewer, tab, varargin) 33 | % Constructor for PlotClickedLabelCurve class 34 | 35 | obj = obj@imagem.gui.Tool(viewer, 'plotLabelCurve'); 36 | 37 | obj.Table = tab; 38 | 39 | obj.Handles.Figure = figure; 40 | h = plotRows(tab, 'color', [.5 .5 .5]); 41 | obj.Handles.AllRows = h; 42 | 43 | obj.XData = get(h(1), 'XData'); 44 | 45 | obj.Handles.MainAxis = get(obj.Handles.Figure, 'Children'); 46 | hold(obj.Handles.MainAxis, 'on'); 47 | obj.Handles.CurrentRow = []; 48 | 49 | end 50 | 51 | end % end constructors 52 | 53 | 54 | %% Methods 55 | methods 56 | 57 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 58 | 59 | doc = obj.Viewer.Doc; 60 | img = doc.Image; 61 | 62 | if ~isLabelImage(img) 63 | return; 64 | end 65 | 66 | point = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint'); 67 | coord = round(pointToIndex(img, point(1, 1:2))); 68 | 69 | % control on bounds of image 70 | dim = size(img); 71 | if any(coord < 1) || any(coord > dim([1 2])) 72 | return; 73 | end 74 | 75 | currentLabel = img(coord(1), coord(2)); 76 | % fprintf('Current Label: %d\n', currentLabel); 77 | if currentLabel < 1 78 | return; 79 | end 80 | 81 | % TODO: should consider the case with missing labels 82 | labelIndex = currentLabel; 83 | ydata = obj.Table.Data(labelIndex, :); 84 | 85 | if isempty(obj.Handles.CurrentRow) 86 | obj.Handles.CurrentRow = plot(obj.Handles.MainAxis, obj.XData, ydata, ... 87 | 'LineWidth', 2, 'Color', 'b'); 88 | else 89 | set(obj.Handles.CurrentRow, 'ydata', ydata); 90 | end 91 | end 92 | 93 | end % end methods 94 | 95 | end % end classdef 96 | 97 | -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/PrintCurrentPointPosition.m: -------------------------------------------------------------------------------- 1 | classdef PrintCurrentPointPosition < imagem.gui.Tool 2 | % Print position of current point. 3 | % 4 | % output = PrintCurrentPointTool(input) 5 | % 6 | % Example 7 | % PrintCurrentPointTool 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-13, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Constructor 20 | methods 21 | function obj = PrintCurrentPointPosition(viewer, varargin) 22 | obj = obj@imagem.gui.Tool(viewer, 'printCurrentPointPosition'); 23 | end % constructor 24 | 25 | end % construction function 26 | 27 | %% General methods 28 | methods 29 | function select(obj) %#ok<*MANU> 30 | end 31 | 32 | function deselect(obj) 33 | end 34 | 35 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 36 | pos = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint'); 37 | fprintf('%f %f\n', pos(1, 1:2)); 38 | end 39 | 40 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 41 | end 42 | 43 | function onMouseMoved(obj, hObject, eventdata) %#ok 44 | end 45 | 46 | end % general methods 47 | 48 | end -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/ScrollImagePosition.m: -------------------------------------------------------------------------------- 1 | classdef ScrollImagePosition < imagem.gui.Tool 2 | % Move the position of the viewbox. 3 | % 4 | % Class SelectLineSegmentTool 5 | % 6 | % Example 7 | % SelectLineSegmentTool 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2012-03-14, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | 19 | %% Properties 20 | properties 21 | Pos0; 22 | 23 | LineHandle; 24 | 25 | end % end properties 26 | 27 | 28 | %% Constructor 29 | methods 30 | function obj = ScrollImagePosition(viewer, varargin) 31 | % Constructor for SelectLineSegmentTool class 32 | obj = obj@imagem.gui.Tool(viewer, 'scrollImagePosition'); 33 | end 34 | 35 | end % end constructors 36 | 37 | 38 | %% ImagemTool Methods 39 | methods 40 | function select(obj) %#ok<*MANU> 41 | % disp('scrool image position'); 42 | obj.Pos0 = []; 43 | end 44 | 45 | function deselect(obj) 46 | end 47 | 48 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 49 | 50 | % disp('click!'); 51 | 52 | % get position of current point 53 | ax = obj.Viewer.Handles.ImageAxis; 54 | pos = get(ax, 'CurrentPoint'); 55 | pos = pos(1,:); 56 | 57 | obj.Pos0 = pos; 58 | end 59 | 60 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 61 | 62 | % clear position -> stop dragging 63 | obj.Pos0 = []; 64 | end 65 | 66 | function onMouseMoved(obj, hObject, eventdata) %#ok 67 | 68 | if isempty(obj.Pos0) 69 | return; 70 | end 71 | 72 | % determine the line current end point 73 | ax = obj.Viewer.Handles.ImageAxis; 74 | pos = get(ax, 'CurrentPoint'); 75 | pos = pos(1,:); 76 | 77 | shift = obj.Pos0 - pos; 78 | if sum(shift == 0) == 2 79 | return; 80 | end 81 | % fprintf('shift: %f, %f\n', shift(1), shift(2)); 82 | 83 | api = iptgetapi(obj.Viewer.Handles.ScrollPanel); 84 | loc0 = api.getVisibleLocation(); 85 | newLoc = loc0 + shift(1:2); 86 | api.setVisibleLocation(newLoc); 87 | 88 | obj.Pos0 = pos; 89 | 90 | end 91 | 92 | 93 | end % end methods 94 | 95 | end % end classdef 96 | 97 | -------------------------------------------------------------------------------- /ImageM/+imagem/+tools/SetPixelToWhite.m: -------------------------------------------------------------------------------- 1 | classdef SetPixelToWhite < imagem.gui.Tool 2 | % Set pixel color to white 3 | % 4 | % output = SetPixelToWhiteTool(input) 5 | % 6 | % Example 7 | % SetPixelToWhiteTool 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inra.fr 15 | % Created: 2011-11-21, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | %% Properties 19 | properties 20 | ButtonPressed = false; 21 | end 22 | 23 | %% Constructor 24 | methods 25 | function obj = SetPixelToWhite(viewer, varargin) 26 | % Creates a new tool using parent gui and a name 27 | obj = obj@imagem.gui.Tool(viewer, 'setPixelToWhite'); 28 | end % constructor 29 | 30 | end % construction function 31 | 32 | %% General methods 33 | methods 34 | function onMouseButtonPressed(obj, hObject, eventdata) %#ok 35 | processCurrentPosition(obj); 36 | obj.ButtonPressed = true; 37 | end 38 | 39 | function onMouseButtonReleased(obj, hObject, eventdata) %#ok 40 | obj.ButtonPressed = false; 41 | end 42 | 43 | function onMouseMoved(obj, hObject, eventdata) %#ok 44 | if ~obj.ButtonPressed 45 | return; 46 | end 47 | processCurrentPosition(obj); 48 | end 49 | 50 | function processCurrentPosition(obj) 51 | doc = currentDoc(obj); 52 | img = doc.Image; 53 | 54 | if ~isGrayscaleImage(img) 55 | return; 56 | end 57 | 58 | point = get(obj.Viewer.Handles.ImageAxis, 'CurrentPoint'); 59 | coord = round(pointToIndex(obj, point(1, 1:2))); 60 | 61 | % control on bounds of image 62 | if any(coord < 1) || any(coord > size(img, [1 2])) 63 | return; 64 | end 65 | 66 | doc.Image(coord(1), coord(2)) = 255; 67 | 68 | updateDisplay(obj.Viewer); 69 | end 70 | 71 | function index = pointToIndex(obj, point) 72 | % Converts coordinates of a point in physical dimension to image index 73 | % First element is column index, second element is row index, both are 74 | % given in floating point and no rounding is performed. 75 | doc = currentDoc(obj); 76 | img = doc.Image; 77 | spacing = img.Spacing(1:2); 78 | origin = img.Origin(1:2); 79 | index = (point - origin) ./ spacing + 1; 80 | end 81 | 82 | end % methods 83 | 84 | end % classdef -------------------------------------------------------------------------------- /ImageM/+imagem/+util/+color/blue2White2Red.m: -------------------------------------------------------------------------------- 1 | function newmap = blue2White2Red(m) 2 | %BLUE2WHITE2RED Blue to white to red color map. 3 | % 4 | % blue2White2Red(M) 5 | % Returns an M-by-3 matrix containing a blue to white to red colormap, 6 | % with white corresponding to the CAXIS value closest to zero. 7 | % This colormap is most useful for images and surface plots with positive 8 | % and negative values. 9 | % 10 | % Example 11 | % figure 12 | % surf(peaks) 13 | % colormap(bluewhitered) 14 | % axis tight 15 | % 16 | % See also HSV, HOT, COOL, BONE, COPPER, PINK, FLAG, 17 | % COLORMAP, RGBPLOT. 18 | 19 | % default number of values 20 | if nargin < 1 21 | m = 256; 22 | end 23 | 24 | % define color "waypoints" 25 | bottom = [0 0 0.5]; 26 | botmiddle = [0 0.5 1]; 27 | middle = [1 1 1]; 28 | topmiddle = [1 0 0]; 29 | top = [0.5 0 0]; 30 | 31 | % It has both negative and positive 32 | % Find ratio of negative to positive 33 | ratio = .5; 34 | neglen = round(m * ratio); 35 | poslen = m - neglen; 36 | 37 | 38 | % Process colors for negative part 39 | new = [bottom; botmiddle; middle]; 40 | len = length(new); 41 | oldsteps = linspace(0, 1, len); 42 | newsteps = linspace(0, 1, neglen); 43 | newmap1 = zeros(neglen, 3); 44 | 45 | for i = 1:3 46 | % Interpolate over RGB spaces of colormap 47 | newmap1(:,i) = min(max(interp1(oldsteps, new(:,i), newsteps), 0), 1)'; 48 | end 49 | 50 | 51 | % Process colors for positive part 52 | new = [middle; topmiddle; top]; 53 | len = length(new); 54 | oldsteps = linspace(0, 1, len); 55 | newsteps = linspace(0, 1, poslen); 56 | newmap = zeros(poslen, 3); 57 | 58 | for i = 1:3 59 | % Interpolate over RGB spaces of colormap 60 | newmap(:,i) = min(max(interp1(oldsteps, new(:,i), newsteps), 0), 1)'; 61 | end 62 | 63 | 64 | % concatenate 65 | newmap = [newmap1; newmap]; 66 | -------------------------------------------------------------------------------- /ImageM/+imagem/+util/+vectorImage/VectorImageMaxChannel.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageMaxChannel < imagem.util.vectorImage.VectorImageView 2 | % One-line description here, please. 3 | % 4 | % Class VectorImageMaxChannel 5 | % 6 | % Example 7 | % VectorImageMaxChannel 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = VectorImageMaxChannel(varargin) 27 | % Constructor for VectorImageMaxChannel class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Implementation of VectorImageView 35 | methods 36 | function res = convert(obj, img) %#ok 37 | data = max(img.Data, [], 4); 38 | res = Image('Data', data, 'Parent', img); 39 | end 40 | end % end methods 41 | 42 | 43 | end % end classdef 44 | 45 | -------------------------------------------------------------------------------- /ImageM/+imagem/+util/+vectorImage/VectorImageNorm.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageNorm < imagem.util.vectorImage.VectorImageView 2 | % One-line description here, please. 3 | % 4 | % Class VectorImageNorm 5 | % 6 | % Example 7 | % VectorImageNorm 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = VectorImageNorm(varargin) 27 | % Constructor for VectorImageNorm class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Implementation of VectorImageView 35 | methods 36 | function res = convert(obj, img) %#ok 37 | res = norm(img); 38 | end 39 | end % end methods 40 | 41 | 42 | end % end classdef 43 | 44 | -------------------------------------------------------------------------------- /ImageM/+imagem/+util/+vectorImage/VectorImageSingleChannel.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageSingleChannel < imagem.util.vectorImage.VectorImageView 2 | % One-line description here, please. 3 | % 4 | % Class VectorImageSingleChannel 5 | % 6 | % Example 7 | % VectorImageSingleChannel 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | ChannelIndex = 1; 22 | end % end properties 23 | 24 | 25 | %% Constructor 26 | methods 27 | function obj = VectorImageSingleChannel(varargin) 28 | % Constructor for VectorImageSingleChannel class. 29 | if ~isempty(varargin) 30 | obj.ChannelIndex = varargin{1}; 31 | end 32 | 33 | end 34 | 35 | end % end constructors 36 | 37 | 38 | %% Implementation of VectorImageView 39 | methods 40 | function res = convert(obj, img) 41 | data = img.Data(:,:,:, obj.ChannelIndex,:); 42 | res = Image('Data', data, 'Parent', img); 43 | end 44 | end % end methods 45 | 46 | 47 | end % end classdef 48 | 49 | -------------------------------------------------------------------------------- /ImageM/+imagem/+util/+vectorImage/VectorImageView.m: -------------------------------------------------------------------------------- 1 | classdef VectorImageView < handle 2 | % An interface for representing a multi-channel image as scalar or RGB. 3 | % 4 | % Class VectorImageView 5 | % 6 | % Example 7 | % VectorImageView 8 | % 9 | % See also 10 | % 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | 19 | %% Properties 20 | properties 21 | end % end properties 22 | 23 | 24 | %% Constructor 25 | methods 26 | function obj = VectorImageView(varargin) 27 | % Constructor for VectorImageView class. 28 | 29 | end 30 | 31 | end % end constructors 32 | 33 | 34 | %% Methods 35 | methods (Abstract) 36 | res = convert(obj, img); 37 | end % end methods 38 | 39 | end % end classdef 40 | 41 | -------------------------------------------------------------------------------- /ImageM/ImageM.m: -------------------------------------------------------------------------------- 1 | function varargout = ImageM(varargin) 2 | % Run a new instance of ImageM application. 3 | % 4 | % ImageM 5 | % Creates a new ImageM window, with a menu and without image. 6 | % 7 | % ImageM(IMG) 8 | % Creates a new ImageM window initialized with the given image. IMG 9 | % should be an instance of Image Object. 10 | % 11 | % VIEWER = ImageM(IMG); 12 | % Returns the ImageM Viewer object created for the input image. 13 | % The viewer contains several fields, among them: 14 | % * Gui: the global GUI that manages the set of frames/viewers 15 | % * Doc: an ImagemDoc object that encapsulates the image together with 16 | % useful information 17 | % * Handles: a set of handles to the widgets that constitute this viewer. 18 | % 19 | % 20 | % Example 21 | % img = Image.read('cameraman.tif'); 22 | % ImageM(img); 23 | % 24 | % See also 25 | % Image, imagem.app.ImagemAppData, imagem.gui.ImagemGUI 26 | % 27 | 28 | % ------ 29 | % Author: David Legland 30 | % e-mail: david.legland@inrae.fr 31 | % Created: 2011-03-10, using Matlab 7.9.0.529 (R2009b) 32 | % Copyright 2011 INRA - Cepia Software Platform. 33 | 34 | % check if image is present, or create one 35 | img = []; 36 | if ~isempty(varargin) 37 | var = varargin{1}; 38 | 39 | if isa(var, 'Image') 40 | % if first argument is an image object, keep it 41 | img = var; 42 | 43 | % if image has no name, use the name of the variable 44 | if isempty(img.Name) 45 | img.Name = inputname(1); 46 | end 47 | 48 | elseif ischar(var) 49 | % if first input is a string, use it to open an image 50 | img = Image.read(var); 51 | 52 | elseif isnumeric(var) || islogical(var) 53 | % if input is numerical array, convert to image and keep input name 54 | img = Image(var); 55 | img.Name = inputname(1); 56 | end 57 | end 58 | 59 | % create the application, and a GUI 60 | app = imagem.app.ImagemAppData; 61 | gui = imagem.gui.ImagemGUI(app); 62 | 63 | % use the GUI to create a new image display 64 | viewer = createImageFrame(gui, img); 65 | 66 | 67 | % returns handle to viewer if requested 68 | if nargout > 0 69 | varargout = {viewer}; 70 | end 71 | -------------------------------------------------------------------------------- /ImageM/go.m: -------------------------------------------------------------------------------- 1 | %GO run script for ImageM 2 | % 3 | % output = go(input) 4 | % 5 | % Example 6 | % go 7 | % 8 | % See also 9 | % 10 | % 11 | % ------ 12 | % Author: David Legland 13 | % e-mail: david.legland@grignon.inra.fr 14 | % Created: 2011-10-18, using Matlab 7.9.0.529 (R2009b) 15 | % Copyright 2011 INRA - Cepia Software Platform. 16 | 17 | % clean up 18 | close all 19 | clear classes %#ok 20 | 21 | % load demo image 22 | img = Image.read('cameraman.tif'); 23 | 24 | % display it! 25 | ImageM(img); 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, David Legland (david dot legland at inra dot fr) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageM 2 | ImageM is a GUI for Image processing with Matlab. 3 | It has similar GUI with ImageJ, a popular open-source software for image analysis written in java. 4 | 5 | The ImageM application is based on the Image class, which gather several image processing algorithms within a unified interface. 6 | 7 | ## Installation 8 | 9 | The application is based on the following dependencies: 10 | 11 | * the "Matlab image class" (https://github.com/mattools/matlab-image-class), for the management of images 12 | * the Image Processing Toolbox 13 | * the MatStats library (https://github.com/mattools/matStats), for the management of data tables 14 | * the Machine Learning and Statistics Toolbox 15 | * the GUI Layout Toolbox V2 (https://fr.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox), for the graphical user interface 16 | * some functionalities also require the MatGeom toolbox (https://github.com/mattools/matGeom). 17 | 18 | All the required toolbox should be installed and the paths set accordingly. A clone of the project should then suffice to run the ImageM application. 19 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs/web/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs/web/index.md: -------------------------------------------------------------------------------- 1 | ## Welcome to GitHub Pages 2 | 3 | You can use the [editor on GitHub](https://github.com/mattools/ImageM/edit/master/docs/index.md) to maintain and preview the content for your website in Markdown files. 4 | 5 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. 6 | 7 | ### Markdown 8 | 9 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for 10 | 11 | ```markdown 12 | Syntax highlighted code block 13 | 14 | # Header 1 15 | ## Header 2 16 | ### Header 3 17 | 18 | - Bulleted 19 | - List 20 | 21 | 1. Numbered 22 | 2. List 23 | 24 | **Bold** and _Italic_ and `Code` text 25 | 26 | [Link](url) and ![Image](src) 27 | ``` 28 | 29 | For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). 30 | 31 | ### Jekyll Themes 32 | 33 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/mattools/ImageM/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file. 34 | 35 | ### Support or Contact 36 | 37 | Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out. 38 | -------------------------------------------------------------------------------- /tests/imagem/app/test_ImagemApp.m: -------------------------------------------------------------------------------- 1 | function test_suite = test_ImagemApp(varargin) %#ok 2 | %TEST_IMAGEMAPP Test case for the file ImagemApp 3 | % 4 | % Test case for the file ImagemApp 5 | 6 | % Example 7 | % test_ImagemApp 8 | % 9 | % See also 10 | % 11 | % 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@grignon.inra.fr 15 | % Created: 2011-10-22, using Matlab 7.9.0.529 (R2009b) 16 | % Copyright 2011 INRA - Cepia Software Platform. 17 | 18 | initTestSuite; 19 | 20 | function test_AddRemoveDocs %#ok<*DEFNU> 21 | 22 | % create an appli 23 | app = imagem.app.ImagemApp; 24 | assertFalse(hasDocuments(app)); 25 | 26 | % create some images 27 | img1 = Image.read('peppers.png'); 28 | img2 = Image.read('cameraman.tif'); 29 | 30 | % create one doc for each image 31 | doc1 = imagem.app.ImagemDoc(img1); 32 | doc2 = imagem.app.ImagemDoc(img2); 33 | 34 | % add images to the doc 35 | app.addDocument(doc1); 36 | assertTrue(hasDocuments(app)); 37 | app.addDocument(doc2); 38 | 39 | app.removeDocument(doc1) 40 | assertTrue(hasDocuments(app)); 41 | app.removeDocument(doc2) 42 | assertFalse(hasDocuments(app)); 43 | 44 | -------------------------------------------------------------------------------- /tests/imagem/util/vectorImage/test_VectorImageMaxChannel.m: -------------------------------------------------------------------------------- 1 | function tests = test_VectorImageMaxChannel 2 | % Test suite for the file VectorImageMaxChannel. 3 | % 4 | % Test suite for the file VectorImageMaxChannel 5 | % 6 | % Example 7 | % test_VectorImageMaxChannel 8 | % 9 | % See also 10 | % VectorImageMaxChannel 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | tests = functiontests(localfunctions); 19 | 20 | 21 | function test_constructor(testCase) %#ok<*DEFNU> 22 | % Test call of function without argument. 23 | 24 | view = imagem.util.vectorImage.VectorImageMaxChannel(); 25 | 26 | assertTrue(testCase, isa(view, 'imagem.util.vectorImage.VectorImageMaxChannel')); 27 | 28 | 29 | function test_convert(testCase) %#ok<*DEFNU> 30 | % Test call of function without argument. 31 | 32 | data = 3 * ones([30 20 4]); 33 | img = Image('Data', data, 'vector', true); 34 | view = imagem.util.vectorImage.VectorImageMaxChannel(); 35 | 36 | res = convert(view, img); 37 | 38 | assertTrue(testCase, isa(res, 'Image')); 39 | assertEqual(testCase, size(res), size(img)); 40 | assertEqual(testCase, res.Data(1,1), 3.0, 'AbsTol', .01); 41 | 42 | -------------------------------------------------------------------------------- /tests/imagem/util/vectorImage/test_VectorImageNorm.m: -------------------------------------------------------------------------------- 1 | function tests = test_VectorImageNorm 2 | % Test suite for the file VectorImageNorm. 3 | % 4 | % Test suite for the file VectorImageNorm 5 | % 6 | % Example 7 | % test_VectorImageNorm 8 | % 9 | % See also 10 | % VectorImageNorm 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | tests = functiontests(localfunctions); 19 | 20 | 21 | function test_constructor(testCase) %#ok<*DEFNU> 22 | % Test call of function without argument. 23 | 24 | view = imagem.util.vectorImage.VectorImageNorm(); 25 | 26 | assertTrue(testCase, isa(view, 'imagem.util.vectorImage.VectorImageNorm')); 27 | 28 | 29 | function test_convert(testCase) %#ok<*DEFNU> 30 | % Test call of function without argument. 31 | 32 | data = 3 * ones([30 20 4]); 33 | img = Image('Data', data, 'vector', true); 34 | view = imagem.util.vectorImage.VectorImageNorm(); 35 | 36 | res = convert(view, img); 37 | 38 | assertTrue(testCase, isa(res, 'Image')); 39 | assertEqual(testCase, size(res), size(img)); 40 | assertEqual(testCase, res.Data(1,1), 6.0, 'AbsTol', .01); 41 | 42 | -------------------------------------------------------------------------------- /tests/imagem/util/vectorImage/test_VectorImageSingleChannel.m: -------------------------------------------------------------------------------- 1 | function tests = test_VectorImageSingleChannel 2 | % Test suite for the file VectorImageSingleChannel. 3 | % 4 | % Test suite for the file VectorImageSingleChannel 5 | % 6 | % Example 7 | % test_VectorImageSingleChannel 8 | % 9 | % See also 10 | % VectorImageSingleChannel 11 | 12 | % ------ 13 | % Author: David Legland 14 | % e-mail: david.legland@inrae.fr 15 | % Created: 2021-01-04, using Matlab 9.8.0.1323502 (R2020a) 16 | % Copyright 2021 INRAE - BIA-BIBS. 17 | 18 | tests = functiontests(localfunctions); 19 | 20 | 21 | function test_constructor(testCase) %#ok<*DEFNU> 22 | % Test call of function without argument. 23 | 24 | view = imagem.util.vectorImage.VectorImageSingleChannel(); 25 | 26 | assertTrue(testCase, isa(view, 'imagem.util.vectorImage.VectorImageSingleChannel')); 27 | 28 | 29 | function test_convert(testCase) %#ok<*DEFNU> 30 | % Test call of function without argument. 31 | 32 | data = 3 * ones([30 20 4]); 33 | img = Image('Data', data, 'vector', true); 34 | view = imagem.util.vectorImage.VectorImageSingleChannel(); 35 | 36 | res = convert(view, img); 37 | 38 | assertTrue(testCase, isa(res, 'Image')); 39 | assertEqual(testCase, size(res), size(img)); 40 | assertEqual(testCase, res.Data(1,1), 3.0, 'AbsTol', .01); 41 | 42 | --------------------------------------------------------------------------------