Im trying to use the Tikz externalize, because for some tikz pictures the file gets to big and exceeds the memory size. I found a lot of other topics with similar problems, but non of the solutions worked for me or I did not implement them well enough.
I'm using Winedt 10.2(also tried Winedt 9)
Mixtex 2.9
The structure of the report:
Final_Report.tex
--Layout.tex
--Simulation_model.tex
----plot_baseunit.tex(Tikz picture)
Final_Report.tex
\documentclass[10pt,a4paper]{report}
\input{./Lay_out/layout.tex}`
\begin{document}
\input{./Chapters/Simulation_Model/Simulation_Model.tex}
\end{document}
layout.tex
\usepackage{tikz,pgfplots}
\usetikzlibrary{arrows,decorations.pathmorphing,shadows,fit,positioning,shapes,chains, plotmarks,automata,positioning}
\usepackage{subcaption}
%\usepackage[pdftex]{graphicx}
\usetikzlibrary{external,calc,patterns,angles,quotes,shapes.geometric,positioning}
\pgfplotsset{plot coordinates/math parser=false}
\tikzexternalize[prefix=figures/,shell escape=-enable-write18]
\newlength\figureheight
\newlength\figurewidth
%Standard figure dimension
\newcommand{\plotx}{12.0cm}
\newcommand{\ploty}{6.0cm}
\newcommand{\plotysub}{3.0cm} %y-dimension of seperate subplots
%Subplot dimensions (2 plots wide subplots)
\newcommand{\subtwoplotx}{5.25cm}
\newcommand{\subtwoploty}{4.5cm}
\tikzstyle{block} = [draw, rectangle, node distance=2.0cm, minimum height=3em, minimum width=4em]
\tikzstyle{sum} = [draw, circle, node distance=2.0cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]
Simulation_model.tex
\begin{figure}[H]
\resizebox{\textwidth}{!}{%
\input{./figures/plot_baseunit.tex}
}%
\caption{The throughput and cycle time of the production line plotted against the process time of a base unit workstation, as bottleneck of the system. The horizontal dotted lines represent the designed throughput and cycle time of the Honda/JLR(green) and Audi/Porsche roof systems(purple).}
\label{fig:Base_unit_through}
\end{figure}
When I try to run this using PDFTeXify it gives the following error.
(figures/plot_baseunit.tex
===== 'mode=convert with system call': Invoking 'pdflatex -halt-on-error -interaction=batchmode -jobname
"figures/Final_Report-figure0" "\def\tikzexternalrealjob{Final_Report}\input{Final_Report}"' ========
! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error-interact
ion=batchmode -jobname "figures/Final_Report-figure0" "\def\tikzexternalrealjob
{Final_Report}\input{Final_Report}"
did NOT result in a usable output file
'figures/Final_Report-figure0' (expected one of .pdf:.jpg:.jpeg:.png:).
Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'.
Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed?
Error messages can be found in 'figures/Final_Report-figure0.log'. If you continue now, I'll try to typeset the picture.
If I just press enter the right figures come out, but this does not work for large files and then the memory size is exceeded.
Thanks in advance!.
Related
A program to run a Schmid-Leiman transformation using SPSS's Matrix language was published in 2005 by Woolf & Preising in Behavior Research Methods volume 37, pages 48 to 58). It is probably not important for you to know what a Schmid-Leiman transformation is, but I'll explain in comments if you feel it is necessary.
In modifying the program for my own data, I'm getting an error I can't figure out:
Error # 12302 in column 12. Text: ,
Syntax error.
Execution of this command stops.
Error in RIGHT HAND SIDE of COMPUTE command.
The MATRIX statement skipped.
Here is the beginning of the code. The error is showing as coming in Line 6:
* Encoding: UTF-8.
* Schmid-Leiman Solution for 2 level higher-order Factor analysis.
Matrix.
* ENTER YOUR SPECIFICATIONS HERE.
* Enter first-order pattern matrix.
Compute F1={.461, .253, -.058, -.069;
.241, .600, .143, .033;
.582, .047, -.077, -.125;
.327, .297, -.120, -.166;
.176, .448, -.240, -.099;
.680, .069, -.036, -.138;
.415, .228, -.091, -.153;
.
.
.
.390, .205, .002, -.098;
.164, .369, -.170, -.047
}.
As shown above, the text generating the error is shown as a comma (,), but the actual text (following the COMPUTE statement) in column 12 is an open bracket ({). So I have no idea what is going on. Can someone help?
For reference, the original code as proposed by Woolf & Preising (2005) is found here;
The Woolf & Preising article is found here
PS: The sample program given in the link above does run on my copy of SPSS. Here's the beginning of that code:
* Schmid-Leiman Solution for 2 level higher-order Factor analysis.
Matrix.
* ENTER YOUR SPECIFICATIONS HERE.
* Enter first-order pattern matrix.
Compute F1={0.099, 0.5647, -0.1521;
0.0124, 0.9419, -0.1535;
-0.1501, 0.6177, 0.4218;
0.7441, -0.0882, 0.1425;
0.6241, 0.2793, -0.1137;
0.8693, -0.0331, 0.0289;
-0.0154, -0.2706, 0.6262;
-0.0914, 0.0995, 0.7216;
0.1502, 0.0835, 0.398}.
I'm trying to use sagetex package, but then I found this kind of problem when running the code
the result
Here is the code I tried to run:
\documentclass{article}
\usepackage{sagetex}
\usepackage{graphicx}
\usepackage{fancyvrb}
\begin{document}
Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.
Here's some Sage code:
\begin{sageblock}
f(x) = exp(x) * sin(2*x)
\end{sageblock}
The second derivative of $f$ is
\[
\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
\sage{diff(f, x, 2)(x)}.
\]
Here's a plot of $f$ from $-1$ to $1$:
\sageplot{plot(f, -1, 1)}
\sageplot[scale=.5]{plot3d(sin(pi*(x^2+y^2))/2,(x,-1,1),(y,-1,1))}
we know that 2010 factors to $\sage{factor(2010)}$
\begin{sagesilent}
m=identity_matrix(QQ,3)
m[0]=m[0]+m[1]
m[1]=m[1]-m[2]
m[2]=m[2]-2*m[1]
m[1]=m[1]+3*m[0]
m[0]=2*m[0]
\end{sagesilent}
Compute the rref of $\sage{m}$
\begin{sageblock}
g(x)=taylor(tan(x),x,0,10)
\end{sageblock}
$$\tan(x)=\sage{g(x)}$$
\end{document}
When I try to compile this, I get:
**** Error in Sage code on line 23 of file.tex! Traceback follows.
Traceback (most recent call last):
File "file.sagetex.sage.py", line 39, in <module>
_st_.plot(_sage_const_1 , format='notprovided', _p_=plot3d(sin(pi*(x**_sage_const_2 +y**_sage_const_2 ))/_sage_const_2 ,(x,-_sage_const_1 ,_sage_const_1 ),(y,-_sage_const_1 ,_sage_const_1 )))
NameError: name 'y' is not defined
Once a single error occurs, the rest of the Sage output may be lost, leading to all of the question marks. The problem is this line:
\sageplot[scale=.5]{plot3d(sin(pi*(x^2+y^2))/2,(x,-1,1),(y,-1,1))}
and in particular, you have not defined y. (In SageMath, x is automatically defined to be a variable, but not y.) If you add this before the plot, it should work:
\begin{sagesilent}
var('y')
\end{sagesilent}
I'm following the protocol outlined here: http://microscopy.duke.edu/HOWTO/countfoci.html
And the commands I'm using are enclosed below.
My problem is that I'm working on massive images (25k x 17k pixels) and sometimes I get accurate values but sometimes I get what I see below. Going by results table (and by RawIntDen/255 to get the actual number of nuclear foci), the cluster highlighted has around 60,000 nuclei! ...which is not the case as you can see by a quick visual examination.
Any idea why this is or what I can do about it?
I've tried re-binarizing the image in the step immediately before measuring. That didn't work. I get this problem whether I do the commands manually or whether I do it via the macro. Any other ideas?
Thanks in advance.
Link to picture: https://www.dropbox.com/s/b7p6wkijf5smlpy/photo%20aug%2009%2C%204%2054%2021%20pm.jpg?dl=0
run("8-bit");
run("Auto Threshold", "method=Triangle white setthreshold show");
run("Convert to Mask");
run("Fill Holes");
run("Dilate");
run("Dilate");
run("Analyze Particles...", "size=50-Infinity display clear summarize add in_situ");
wait(30000);
run("Revert");
run("Find Maxima...", "noise=7 output=[Single Points] exclude");
run("ROI Manager...");
roiManager("Show None");
roiManager("Show All");
run("Set Measurements...", "area mean min integrated redirect=None decimal=3");
roiManager("Measure");
wait(30000);
roiManager("Save", path + ".zip");
saveAs("Results", path + ".xls");
close();
your pictures seem to be quite big in Pixels. Your defined particle size is "50 - infinity". I think this is too small, try something bigger than 50. hope that solves the Problem.
P.S.: We've tried to cope with similar problems also using this algorithm, perhaps that's going to help you: http://focinator.oeck.de/.
The same question as Building Lates/Tex arguments in lua with a more complex case :
Part II
A more adequate model :
I try to replace the plot arguments by a lua production:
Original:
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{(\x-1.0)^2.0*(\x+3.0)});
\end{tikzpicture}%
Replacement by a "manual" macro : works fine
\def\tempD{(\x-1)*(\x-1)*(\x+3)}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{\tempD}); % works fine
\end{tikzpicture}%
Trials to use a string produced by lua to replace the manual macro : still to be found
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
%\draw[smooth,samples=100,domain=-3.0:2.0] plot(\x,{\strfunc??????}); % the correct \strfuncXX is still to be found !
\end{tikzpicture}%
Trials to find the correct \strfuncXX, taking account egreg's infos :
\def\strfuncA{\luaexec{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails in draw, probably because it is not expanded enough as an argument of draw
%\edef\strfuncAA{\luaexec{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails because \luaexec non expandable
\def\strfuncB{\directlua{tex.write("(\\x-1)*(\\x-1)*(\\x+3)")}} % fails because \directlua has a problem managing the "\\"
\def\strfuncC{\directlua{tex.write("(x-1)*(x-1)*(x+3)")}}
\edef\strfuncCC{\directlua{tex.write("(x-1)*(x-1)*(x+3)")}} % works fine ... except that we get an expression with xs instead of \xs
\def\strfuncD{\directlua{tex.write("(\string\ x-1)*(\string\ x-1)*(\string\ x+3)")}} % \strfuncD fails (why ?)
%\edef\strfuncDD{\directlua{tex.write("(\string\ x-1)*(\string\ x-1)*(\string\ x+3)")}} % \strfuncD fails so \edef will fail
Moving from \luaexec to \luadirect (or \directlua) created a problem with the compulsory \x I have to produce that I cannot solve.
Please take a look at the screenshot below and see if you can tell me why this won't work. The examples in on the reference page for TextRecognize look pretty impressive, I don't think recognizing single letters like this should be a problem. I've tried resizing the letters as well as having the image sharpened.
For convenience in case you want to try this yourself I have included the image that I use at the bottom of this post. You can also find plenty more like this by searching for "Wordfeud" in Google Image Search.
Very cool question!
TextRecognize uses heuristics to recognize whole words from the English language. This is
the gotcha that makes recognizing single letters very hard
Consider the following line of thought:
s = Import["http://i.stack.imgur.com/JHYuh.png"];
p = ImagePartition[s, 32]
Now pick letters to form the English word 'EXIT':
x = {p[[1, 13]], p[[6, 6]], p[[3, 13]], p[[1, 12]]}
Now clean up these images a bit, like so:
d = ImageAssemble[ Map[ImageTake[#, {3, 27}, {2, 20}] &, x ]];
Then this returns the string "EXIT":
TextRecognize[d]
This is an approach completely different from using TextRecognize, so I am posting this as a separate answer. It uses the same image recognition technique from the How do I find Waldo with Mathematica.
First get the puzzle:
wordfeud = Import["http://i.stack.imgur.com/JHYuh.png"]
And then get the pieces of the puzzle:
Grid[pieces = ImagePartition[s, 32]]
Let's be interested in the letter E:
LetterE = pieces[[4, 3]]
Get the correlation image:
correlation =
ImageCorrelate[wordfeud, Binarize[LetterE],
NormalizedSquaredEuclideanDistance]
And highlight the matches:
positions = Dilation[ColorNegate[Binarize[correlation, .1]], DiskMatrix[20]];
found = ImageMultiply[wordfeud, ImageAdd[ColorConvert[positions, "GrayLevel"], .5]]
As before, this requires a bit of tuning on binarizing the correlation image, but other than
that this should help to identify bits and pieces of this puzzle.
I thought the quality of your image might be interfering. Binarizing your image did not help : recognition was zilch. I also tried a very sharp black and white image of a crossword puzzle solution. (see below) Again, nothing was recognized whether in regular or binarized format.
So I removed the black background leaving only the letters and their thin black frames. Again, recognition was about 0%.
When I removed the frames from around some of the letters AND binarized the image the only parts that were recognizable were those regions in which there was nothing but letters. (see below)
Notice in the output below, ANTS, TIRES, and TEXAS are correctly identified (as well as VECTORS), but just about nothing else.
Notice also that, even though the strings were widely spaced, mma interpreted them as words, rather than separate letters. Note "TEXAS" instead of "T E X A S".
TextRecognize[Binarize#img]
(* output *)
ANTS FFWWW FEEWF
E R o If IU I?
E A FI5F WWWFF 5
5552? L E F F
T s E NTT BT|
H0RWW#0WVlWF;EE F
5 W E ; OCS
FOFT W W R AL%AE
A TT I T ? _
i iE#W'NF WG%S W
A A EW F I i
SWWTW W ALTFCWD N
H A V 5 A F F
PLATT EWWLIGHT
W N E T
HE TIRES C
TEXAS VECTORS
I didn't have the patience to completely clean up the image. It would have been much faster to retype the text by hand.
Conclusion: Don't use text recognition in mma unless you have absolutely clear text against an even-colored, bright, preferrably white, background.
The results also varied depending on the file format used. Avoid .pdf altogether.
Edit
acl captured and tried to recognize the last 5 lines (above Edit). His results (in a comment below): mostly gibberish.
I decided to do the same. But since Prashant warned that text size makes a difference, I zoomed in first so that the text appear (to my eyes) to be about 20 pica. Below is the picture of the text I scanned and TextRecognized.
Here's the result of an unbinarized TextRecognize (at that large size):
Gliii. Q lk-ii`t`*¥ if EY £\[CloseCurlyDoubleQuote]1\[Euro]'EE \
Di'¥C~E\"P ITF SKI' T»f}!E'!',IL:?E\[CloseCurlyDoubleQuote] I 2 VEEE5\
\[CloseCurlyQuote] LEP \"- \"VE
1. ur e=\\..r.1.»».»\\\\ rw r 1»»\\|a'*r | r .fm -»'-an \
\[OpenCurlyQuote] -.-rr -_.»~|-.'i~-.w~,.-- nv n.w~»-\
\[OpenCurlyDoubleQuote]~"
Now, here's the result for the TextRecognize of the binarized image. The original image was a .png from Jing.
I didn't have the patience to completely clean up the image. It would \
have been much faster to retype the
text by hand.
Conclusion: Don't use text recognition in mma unless you have \
absolutely clear text against an even-
colored, bright, preferrably white, background.
The results also varied depending on the file format used. Avoid .pdf \
altogether.