Welcome to the community, @nicolasmart!
Would you be able to elaborate a bit on your use case? Is your plugin specific to the DICOM file format, or can you rely on libraries such as #scifio and #bio-formats for reading of pixel data and metadata?
Does it have to be a (Java) plugin, or would a script (e.g. Jython or Groovy) do it as well? In my experience, a script is enough in most cases actually.
That’s the ImageJ1.x way of getting an image, yes. As @nicolasmart was specifically asking about an ImageJ 2.x plugin (see topic title), let me elaborate for completeness:
you can get the currently active image (or an image specified as input from calling code) by using #scijava parameters:
private Dataset dataset;
if you need to load an image from file(s), you can use the
private DatasetIOService datasetIOService;
Dataset data = datasetIOService.open(filepath);