Latex, display a long image in multiple page? - image

(Please don't move my post to Tex, I can't post image there.)
I have a long UML diagram, I use the following code.
The figure is about two and a half page long, but only the first page is showing, and the lower part of the figure is missing. How do I display the whole diagram in multiple page?
Exactly what code should I add?
\usepackage{graphicx}
......
\includegraphics[height= 81.3cm, width=18cm]{myImage.png}
\captionof{figure}{Sequence Diagram}
Screenshot:

You can use the viewport option of \includegraphics to display a specific portion of the image. By using this command three times you can display your image in three portions.
The viewport option takes 4 arguments:
The first two values are the (x,y) coordinates (in pixels) of the lower left corner of the portion of the image file you want to include.
The second two values are the coordinates of the upper right corner.
For example, the command \includegraphics*[viewport=0 0 100 100]{myImage.png} would display the bottom-left corner of the image. Note that you need the * in order to actually crop the image; otherwise it will only be shifted.

Related

Use FFMPEG to put images separately inside a "box" and keeping their original positions of the X and Y boundaries and maybe modify their offsets

I have a collection of images, for this example, I created 3 images that have different sizes, but the image itsself is the same, except it is moved more down or left or right.
1: 2: 3:
These are the images. The total sizes of all images together is 35x39, so that means that they need to go inside an 35x39 image so it can later be used to craft them into a GIF as example. Since "crop" does not really work as it crops it smaller and can't make them bigger and I can't imagine it being the best solution for that anyway, perhaps.
So this is the invisible 35x39 sized box.
image:
So what I'm trying to do is to figure out how I can put each of these images separately in the 35x39 sized box, but maintaining the original X position or the Y position or both, from the boundaries of the images. I'm trying to figure out how I can do this for other transparent images for similar things, mostly used to craft animations. Here into a GIF out of image collections, but the images need to be fixed first.
I tried to look in the FFMPEG documentation, but there's many many filters and etc. that I had a few issues finding the right thing. I'm also not sure if it is also then possible to change the offset of the X and Y, because I think if there's something to make it keep the original position of X and Y, then I also think that there's probably something to change the offset of it aswell.
 
End result of the images could basically be:
1: 2: 3:
This end result example of the images, basically have their X aligned on the top and Y aligned on the left. I'm not sure if you can call it "original X position", because if I compare it to Photoshop's special paste and keep at original position, it puts the first image a bit more down as example, for some reason. So I just moved the X all the way to the top and the Y all the way to the left.

Save image in original resolution with imfindcircle plot in Matlab

I have a really long picture where I use imfindcircles on. But I need to check if the right ones are found. It is a 158708x2560 logical.
So I have:
[centers, radii] = imfindcircles(I,[15 35],'ObjectPolarity','bright','Sensitivity',0.91);
figure(1)
imshow(I)
viscircles(centers,radii);
and I want to save that output you see in the figure box (binary image with circles on it) to a image file. File format doesn't matter as long as it has the same resolution of 158708x2560 pixel.
Every suggestion I find online alters the resolution or makes the image broader, like when saving the figure directly you get a huge grey border and resolution goes down.
What would also work is a way to zoom into the figure but the zoom option in the figure menu does not magnify correctly. It does magnify but the image stays really thin so you can't see a thing.
Matrix: https://www.dropbox.com/s/rh9wakimc7atfhg/I.mat?dl=0
There are two round spots repeating. I want to find those, not the others. And export the image with the circles plotted over it.

How do I make the plot generated marker more noticeable?

I have the coordinate indicating the start of each letter within a word. I have set the plot function to make a red circle at that coordinate like so:
The problem is that the paper I am adding this image to has a structure of 2 columns per page. And when I add 2 of the above image to the same column, the circles become very small and difficult to notice.
I tried instead of circles to make triangles or pentagrams. I get the same result, they become too small to distinguish.
How can I make this more distinguishable? Especially when its printed in black and white.
You can change the marker size of the markers, and\or overlay two different markers one of the other. For example:
x=1:100;
y=rand(1,100);
plot(x,y); hold on
n=20:20:60;
plot(x(n),y(n),'r+','MarkerSize',30,'LineWidth',2);
plot(x(n),y(n),'ro','MarkerSize',15,'LineWidth',2);
There are many other degrees of freedom you can use to add \ change to this. It is a very basic question that you could have answered yourself if you read the documentation of plot in TMW website.

Invoice / OCR: Detect two important points in invoice image

I am currently working on OCR software and my idea is to use templates to try to recognize data inside invoices.
However scanned invoices can have several 'flaws' with them:
Not all invoices, based on a single template, are correctly aligned under the scanner.
People can write on invoices
etc.
Example of invoice: (Have to google it, sadly cannot add a more concrete version as client data is confidential obviously)
I find my data in the invoices based on the x-values of the text.
However I need to know the scale of the invoice and the offset from left/right, before I can do any real calculations with all data that I have retrieved.
What have I tried so far?
1) Making the image monochrome and use the left and right bounds of the first appearance of a black pixel. This fails due to the fact that people can write on invoices.
2) Divide the invoice up in vertical sections, use the sections that have the highest amount of black pixels. Fails due to the fact that the distribution is not always uniform amongst similar templates.
I could really use your help on (1) how to identify important points in invoices and (2) on what I should focus as the important points.
I hope the question is clear enough as it is quite hard to explain.
Detecting rotation
I would suggest you start by detecting straight lines.
Look (perhaps randomly) for small areas with high contrast, i.e. mostly white but a fair amount of very black pixels as well. Then try to fit a line to these black pixels, e.g. using least squares method. Drop the outliers, and fit another line to the remaining points. Iterate this as required. Evaluate how good that fit is, i.e. how many of the pixels in the observed area are really close to the line, and how far that line extends beyond the observed area. Do this process for a number of regions, and you should get a weighted list of lines.
For each line, you can compute the direction of the line itself and the direction orthogonal to that. One of these numbers can be chosen from an interval [0°, 90°), the other will be 90° plus that value, so storing one is enough. Take all these directions, and find one angle which best matches all of them. You can do that using a sliding window of e.g. 5°: slide accross that (cyclic) region and find a value where the maximal number of lines are within the window, then compute the average or median of the angles within that window. All of this computation can be done taking the weights of the lines into account.
Once you have found the direction of lines, you can rotate your image so that the lines are perfectly aligned to the coordinate axes.
Detecting translation
Assuming the image wasn't scaled at any point, you can then try to use a FFT-based correlation of the image to match it to the template. Convert both images to gray, pad them with zeros till the originals take up at most 1/2 the edge length of the padded image, which preferrably should be a power of two. FFT both images in both directions, multiply them element-wise and iFFT back. The resulting image will encode how much the two images would agree for a given shift relative to one another. Simply find the maximum, and you know how to make them match.
Added text will cause no problems at all. This method will work best for large areas, like the company logo and gray background boxes. Thin lines will provide a poorer match, so in those cases you might have to blur the picture before doing the correlation, to broaden the features. You don't have to use the blurred image for further processing; once you know the offset you can return to the rotated but unblurred version.
Now you know both rotation and translation, and assumed no scaling or shearing, so you know exactly which portion of the template corresponds to which portion of the scan. Proceed.
If rotation is solved already, I'd just sum up all pixel color values horizontally and vertically to a single horizontal / vertical "line". This should provide clear spikes where you have horizontal and vertical lines in the form.
p.s. Generated a corresponding horizontal image with Gimp's scaling capabilities, attached below (it's a bit hard to see because it's only one pixel high and may get scaled down because it's > 700 px wide; the url is http://i.stack.imgur.com/Zy8zO.png ).

Superimpose labeling onto RGB image

I have two matrices where one is RxCx3 (RGB image) and the other is RxC (labelings). Most of the labels are zero and I would like to paint the non-zero labels on the RGB image. More specifically, I would like to superimpose the figure:
imagesc(labels)
onto the figure:
imshow(rgb)
except the zero values in labels. What is the quickest way to achieve it?
Well here's my interpretation of your problem: You want to superimpose non-zero elements of a matrix onto an image (an example of this might be a heat map).
This page here will give you everything you need regarding the non-zero aspect, but generally you will do something like
find(Labels)
inside a processing section that will then only process those elements of "Labels" > 0. (You can make the expression inside "find" way more complex if your needs change)
Find - Matlab
To actually superimpose the image though (you require labels), you need to make a decision. Physically alter the image to be displayed to show the labels or overlay the labels transparently. The following page has great information on achieving this result:
Overlaying Image in MATLAB
I suspect for your requirements, you'd want to take the transparency route (I would recommend it as well)

Resources