Using ImageJ as a plugin for mass image analysis

3 次查看(过去 30 天)
I am currently trying to use ImageJ as a plug-in where I can open a file and have the script apply certain settings to it (Image>Adjust>Color Threshold> Color Threshold: B&W, Brightness = 75). I've been able to open the image, but I'm having trouble applying the settings I want. The "Apply" command isn't working and I am running out of ideas. I've attached the code below. Can anyone help?
javaaddpath('C:\Program Files\MATLAB\R2023b\java\mij.jar');
javaaddpath('C:\Program Files\MATLAB\R2023b\java\ij.jar');
MIJ.start;
% Browse for the JPEG or TIFF file
[filename, filepath] = uigetfile('*.*');
imagePath = fullfile(filepath, filename);
% Open the image using MIJ
MIJ.run('Open...', ['path=[' imagePath ']']);
% Open the Color Threshold dialog
MIJ.run('Color Threshold...');
% Set color space to B&W
MIJ.run('Set... ', ['thresholded color=B&W']);
% Close the Color Threshold dialog (applies the changes)
MIJ.run('Close');

回答(1 个)

Rahul
Rahul 2025-4-8
I understand that you wish to apply color threshold to your image and are not able to "Apply" it while running the MIJ.run('Close') command. The following command can be used to apply the required threshold:
MIJ.run('Convert to Mask');
% After this commmand to close tha pplication run
MIJ.run('Close All');
The following MATLAB Answer and File Exchange submission can be referred to know more about MIJ commands in MATLAB:
Thanks.

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by