Issue with Exporting High-Resolution Mineral Images from CorelDRAW for MATLAB Processing

  • Image Preparation: I have outlined the minerals in CorelDRAW, and the quality looks excellent within the software.
  • Exporting Issue: When I export the image to PNG format, the resolution becomes pixelated, making it unsuitable for further processing in my MATLAB code.
  • Code Requirements: My MATLAB code accepts PNG, TIFF, JPEG, and BMP formats.
  • PNG Issue: The resolution is poor and pixelated.
  • Other Formats (TIFF, JPEG, BMP): The background of the image is selected, which is not desired.
Question:
  • What settings should I use in CorelDRAW to export a high-resolution image in PNG format without losing quality?
  • How can I ensure that the background is not selected when exporting to TIFF, JPEG, or BMP formats?
Any advice or tips would be greatly appreciated!
Thank you!

3 Comments

Any image read by imread() will be a raster image, since that's the only thing imread() does. All PNG, TIFF, etc files have finite resolution, and the only way to set that is during export from the application which generates the raster data from the vector image. Raster images are always pixelated, since they're composed of discrete pixels. If you need it to be raster, and you need it to have more resolution, export a larger image.
I don't know what you mean by "ensure that the background is not selected when exporting to TIFF, JPEG, or BMP". I'm going to guess that you mean that you're trying to export the image with alpha content. JPG doesn't support alpha. BMP supports alpha, but many applications (including MATLAB imread()) don't handle it. I don't know if CorelDraw does. Alpha data can be crammed into a TIFF (most anything can), but I'd have to guess whether CorelDraw would, or how it would do it. In any case, none of those options will avoid the fact that raster images are not vector images.
Depending on what you're trying to do, alpha content may not be necessary or useful. If you're using it for image composition, then maybe it's convenient. If you're processing the image (e.g. binarization, blob analysis), then antialiasing and transparency are probably not helpful.
Assuming those are all simple path objects, you can save the vector image as an SVG file and import it using loadsvg()
... but there is probably other work that needs to be done if you need the vector data to be registered to some raster image or a fixed coordinate space. Since I don't know what you're doing with these images in MATLAB, I don't know what to suggest.
I'm going to elaborate on the CDR-SVG import suggestion. For this example, I'm assuming it's okay to import vertex data in the coordinate space defined by the geometry of a reference image. I'm going to trace out a few regions with the path tool and then import them.
% this needs to be zipped for the forum
unzip intersections.svg.zip
% the reference image from which the SVG is transcribed
inpict = imread('manytriangles.png');
% filename of manually-fit svg file
% the contents of this SVG are three path objects
% and an embedded copy of the reference image
fname = 'intersections.svg';
% the vertex data is assumed to be used with respect
% to the coordinate space defined by the original image
xrange = [1 size(inpict,2)];
yrange = [size(inpict,1) 1]; % y-axis of images are reversed!
% spline discretization parameter [0 1]
% we're using polylines, so this is 1
coarseness = 1;
% get the embedded image geometry
% in order to define the vertex locations in image space
str = fileread(fname);
str = regexp(str,'((?<=<image)(.*?)(?=\/>))','match');
pbx = regexp(str,'((?<=x=")(.*?)(?="))','match');
pby = regexp(str,'((?<=y=")(.*?)(?="))','match');
pbw = regexp(str,'((?<=width=")(.*?)(?="))','match');
pbh = regexp(str,'((?<=height=")(.*?)(?="))','match');
pbrect = [str2double(pbx{1}{1}) str2double(pby{1}{1}) ...
str2double(pbw{1}{1}) str2double(pbh{1}{1})];
% get coordinates representing the curve
S = loadsvg(fname,coarseness,false);
% if there are multiple paths you want to extract
% you'll need to do do the rescaling, etc for each element of S
for k = 1:numel(S) % there are multiple curves
x = S{k}(:,1);
y = S{k}(:,2);
% rescale to fit data range
x = xrange(1) + diff(xrange)*(x-pbrect(1))/pbrect(3);
y = yrange(1) + diff(yrange)*(pbrect(4) - (y-pbrect(2)))/pbrect(4);
% shove the prepared data back into S for later
S{k} = [x y];
end
% show the original image
imshow(inpict); hold on
% plot the overlaid polygons directly from vertex data
for k = 1:numel(S)
x = S{k}(:,1);
y = S{k}(:,2);
plot(x,y,'y','linewidth',2)
end
grid on;
xlim(xrange)
ylim(sort(yrange))
I don't know if that's helpful.

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 23 Aug 2024

Commented:

DGM
on 24 Aug 2024

Community Treasure Hunt

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

Start Hunting!