Load PDF Image into MATLAB - matlab

I have a PDF of building schematics. I would like to load it into MATLAB, and visualize the image via a GUI, so I can measure distances and such for some calculations.
I have no idea if this is even possible?
Furthermore, the PDF has an embedded scale (i.e. 1 cm = 1 meter). If I can extract this as well, that would be awesome.
I found extractFileText which can be used to extract text, but not much else.

I found the easiest way to do this was to convert the pdf to a image, for example using imagemagick. See this question
If you add an example of the image someone might be able to suggest some ideas for extracting the scale information using image processing.

Related

Matlab imwrite() quality

I'm very new to Matlab, though I know a few other programming languages, so please forgive me if this is something simple. I have not been able to find any answers to this, either on StackOverflow or elsewhere.
I produce a figure using the following code:
figure(6),imageplot(P); drawnow;
Which looks like this:
I then save this image to my computer using the following commands:
imwrite(P, 'images/plot.png');
And the resulting image is tiny, and missing some of the color information:
If, however, I utilize the save function in the open figure (image #1) and save it manually, I get exactly what I want, which is that exact image stored on my computer.
How would I program that? I assumed that imwrite() would just write the image directly, but apparently I'm doing something wrong. Any advice? Perhaps it has something to do with the imageplot command? I cannot seem to get that to work in imwrite.
Update: Based on the comments below, I have begun using "imresize" with the "nearest" option. This scales the image properly, but the resulting image is still curiously darker (and therefore has less information) than if I hit the "save" button in the figure.
Image saved from figure:
Image using "imresize" with "nearest" option:
The MATLAB imwrite command saves exactly the number of pixels as specified in your image matrix. This is the actual result of your computation; the reason the output is "tiny" is because it is supposed to be. To make it larger, would be to simply scale/zoom it as required.
The save figure option however does something quite different: it rasterizes the the output you obtain in the figure window and gives you the option for saving it as an image. This is evident in the fact that when you do so, you obtain a white background in addition to your result which is really just the grey background you see before you save it; this can be adjusted by resizing the figure window before utilizing the save option.
If you're looking to simply make the output figure larger, I would recommend using something along the lines of the imresize command.
Say, if you want the default size to be twice the size of the real result, simply use:
imresize(P, 2.0);
For more options, try help imresize.
The command you need for the "Save As..." functionality of figures is called "print". I often use
print(gcf, '-dpng', 'some_filename.png')
or
print(gcf, '-depsc', 'some_filename.eps','-r0')
to save a figure as it is shown on screen. The format png offers a small filesize and excellent quality, and it is understood by most image viewers and browsers. The eps format is a vector format, which I use for printig. The '-r0' option specifies "use the same size as given by the screen resolution" for the vector format properties.

How to manually segment and label ROIs in an image in Matlab?

I'm a newbie to Matlab. I'm basically attempting to manually segment a set of images and then manually label those segments also. I looked into the imfreehand(), but I'm unable to do this using imfreehand().
Basically, I want to follow the following steps :
Manually segment various ROIs on the image (imfreehand only lets me draw one segment I think?)
Assign labels to all those segments
Save the segments and corresponding labels to be used further (not sure what format they would be stored in, I think imfreehand would give me the position and I could store that along with the labels?)
Hopefully use these labelled segments in the images to form a training dataset for a neural network.
If there is some other tool or software which would help me do this, then any pointers would be very much appreciated. (Also I am new to stackoverflow, so if there is any way I could improve on the question to make it clearer, please let me know!) Thanks!
Derek Hoiem, a computer vision research at the University of Illinois, wrote an object labelling tool which does pretty much exactly what you asked for. You can download it from his page:
http://www.cs.illinois.edu/homes/dhoiem/software/index.html

improving resolution of jpeg images in matlab

I have a jpeg which has reasonable resolution. I am looking for a method of improving the resolution of the image and then exporting it into a pdf file.
Currently I have imported the jpeg:
Img = imread('F:Work\fig.jpg');
From here I was hoping of exporting the figure by using the export_fig function:
https://sites.google.com/site/oliverwoodford/software/export_fig
But I am struggling on generating the figure which is required prior to exporting the image.
What part of the figure creation process are you struggling with? The general approach I would use is
Img = imread('F:Work\fig.jpg');
bigImg = imresize(Img,2);
imshow(bigImg);
export_fig test.png -native;
Check Matlab's documentation for different interpolation options that can be used when resizing images.

Extracting Filiform Areas using MATLAB

how can I extract filiform areas on the center of an image using MATLAB ?
A picture and some more details on the structures you want to extract would make it easier to answer.
You could get started using this: http://www.mathworks.com/matlabcentral/fileexchange/25157-blobsdemo

Perl+Image::Magick usage: how to assemble several areas in one image into a new image?

I'm new to ImageMagick and haven't figured out how to assemble several areas into a new image.
E.g., I know the "geometry" of words "hello" and "world" respectively in an image, what I need to do
is to retrieve the word images and put then into one line image while keep their relative positions.
Question1: Suppose I use the perl API, how should I use Composite() or other correct methods to do this?
my $geom = sprintf('%dx%x+%d+%d', $word->{width}, $word->{height}, $offsetx, $offsety);
$x = $lineimg->Composite($wordimg, $geom);
warn "$x" if "$x";
Suppose $lineimg's size is big enough to hold all word images and the geometry has been computed.
This code gives out a complain by ImageMagick:
Exception 410: composite image required `Image::Magick' # Magick.xs/XS_Image__Magick_Mogrify/7790 ...
Question2: currently I only know how to crop a word image out of the original one and then Clone() method
to restore the original image. Is there a way to copy instead of crop a specific area from a image? This way
can save the time to copy back and forth the whole image several times.
Does anybody know how to write this kind of processing? I appreciate all your help and suggestions!
-Jin
From the sounds of things Image::Magick is not the right tool for your task. Image::Magick is generally for manipulating entire image - filtering, scaling, converting between formats etc.
Consider the GD module, which can do just about any of the drawing operations you will need.