Unrecognized Quartz MS font - tesseract

I tried to generate the image with the Quartz MS font as follows.
Then use jTessBoxEditorFX to generate the box file, as follows.
0 26 23 97 125 0
1 169 26 189 122 0
2 209 23 279 124 0
3 305 23 370 124 0
4 391 25 461 121 0
5 481 23 551 124 0
6 571 23 641 124 0
7 665 27 731 124 0
8 753 24 822 124 0
9 842 24 912 125 0
The traineddata cannot be recognized normally. Is there any problem with my practice?
Whether there are similar experiences of seniors can guide me, thank you.

Related

In KDB, how do I sum the previous 3 numbers in a list?

Say I have a list of numbers:
j: (til 40)*9
0 9 18 27 36 45 54 63 72 81 90 99 108 117 126 135 144 153 162 171 180 189 198 207 216 225 234 243 252 261 270 279 288 297 306 315 324 333 342 351
What's the most elegant way to get the sum of the previous 3 (or n) numbers in the list? (Ideally considering large RAM constrained lists).
Does this work?
q)3 msum j
0 9 27 54 81 108 135 162 189 216 243 270 297 324 351 378 405 432 459 486 513 ..

Concatenating column vector to a cell array

I have a matrix in Matlab as below:
a =
1 169 158 147
1 104 165 66
728 105 276 43
950 113 971 40
1 107 810 23
227 133 48 15
618 131 107 20
class(a)
ans =
'double'
I want to add a column to this matrix. When I try this command, i get a wrong result:
A={1;2;3;4;5;6;7}
vertcat(A,a)
Answer is like below:
What I wanted was:
1 1 169 158 147
1 1 104 165 66
1 728 105 276 43
1 950 113 971 40
1 1 107 810 23
1 227 133 48 15
1 618 131 107 20
What mistake I am making and how to I fix it?
Thanks
P.S: I am new to Matlab

Make histogram of pixel intensities without imhist

I have used the unique command to get the unique pixel intensities from my image. Then I tried to make a histogram using them, but it doesn't use all of the intensity values
I = imread('pout.tif');
[rows, columns] = size(I);
UniquePixels=unique(I);
hist=histogram(UniquePixels)
An alternative approach would be to use accumarray combined with unique. I would specifically use the third output of unique to transform your data into a consecutive sequence of 1 up to N where N is the total number of unique intensities, then leverage the first output of unique that will give you the list of unique intensities. Therefore, if the first output of unique is A and the output of accumarray is B, the effect is that at location B(i), this gives the total number of intensities of A(i).
Therefore:
[UniquePixels, ~, id] = unique(I);
histo = accumarray(id, 1);
UniquePixels gives you all unique pixels while histo gives you the counts of each unique pixel corresponding to each element in UniquePixels.
Here's a quick example:
>> I = randi(255, 10, 10)
I =
42 115 28 111 218 107 199 60 140 237
203 22 246 233 159 13 100 91 76 198
80 59 2 47 90 231 62 210 190 125
135 233 198 68 131 241 103 4 49 112
43 39 209 38 103 126 25 11 176 114
154 211 222 35 20 125 34 44 47 79
68 138 22 222 62 87 241 166 94 130
167 255 102 148 32 230 244 187 160 131
176 20 67 141 47 95 147 166 199 209
191 113 205 37 62 29 16 115 21 203
>> [UniquePixels, ~, id] = unique(I);
>> histo = accumarray(id, 1);
>> [UniquePixels histo]
ans =
2 1
4 1
11 1
13 1
16 1
20 2
21 1
22 2
25 1
28 1
29 1
32 1
34 1
35 1
37 1
38 1
39 1
42 1
43 1
44 1
47 3
49 1
59 1
60 1
62 3
67 1
68 2
76 1
79 1
80 1
87 1
90 1
91 1
94 1
95 1
100 1
102 1
103 2
107 1
111 1
112 1
113 1
114 1
115 2
125 2
126 1
130 1
131 2
135 1
138 1
140 1
141 1
147 1
148 1
154 1
159 1
160 1
166 2
167 1
176 2
187 1
190 1
191 1
198 2
199 2
203 2
205 1
209 2
210 1
211 1
218 1
222 2
230 1
231 1
233 2
237 1
241 2
244 1
246 1
255 1
If you double check the input example and the final output, you will see that only the unique pixels are shown combined with their counts. Any bins that were zero in count are not shown.

Matlab Spearman Correlation PVAL = 0?

I am conducting Spearman's Correlation with two data sets with 300 objects. These are my variables and commands:
a = [1:300]
b = [1 2 5 11 9 7 24 10 31 23 3 40 6 17 14 20 16 12 33 46 70 37 87 43 98 26 59 58 77 100 35 42 78 80 243 36 33327 4 83 160 163 198 86 94 406 111 28 29 55 113 239 295 110 196 177 32679 229 342 305 300 254 96 210 514 167 172 232 190 117 32081 25 158 19333 241 82 149 159 66 178 24487 68 30 1016 725 266 391 638 348 320 681 242 319 228 381 408 442 202 369 471 821 191 426 8 270 211 2266 619 576 441 680 3431 1167 723 74 318 556 640 395 1059 579 614 212 325 437 323 687 373 599 26637 985 54 84 802 724 154 417 240 1120 818 2309 462 109 104 509 494 427 57 2475 549 396 419 123 580 79 225 1132 351 76 16859 596 862 315 470 992 257 120 409 751 832 285 1534 714 1665 1376 2129 678 416 721 209 31971 183 356 1346 1015 1003 188 1076 1634 608 1056 338 308 145 418 625 1313 121 2484 996 783 329 1185 697 157 1100 175 622 235 456 277 166 2700 1439 461 653 433 540 1191 234 774 1894 1004 741 1062 948 48 99 405 797 237 1104 2286 22620 1429 30672 1808 169 458 22 1115 10660 872 474 1063 88 1727 1017 1107 1398 1519 703 1092 1027 272 263 1152 1770 1099 507 385 2118 19356 1778 2458 410 2110 7522 17166 4065 15136 13294 10876 17174 2434 9898 5663 13594 10506 11552 15635 9322 3223 8949 12388 13216 13851 13852 6696 12177 4700 17199 2067 11110 15486 5664 6593 4701 527 8616 268]
[RHO,PVAL] = corr(b',a','Type', 'Spearman')
RHO =
0.6954
PVAL =
0
Out of the 5 comparisons I made with other data sets of 300 objects, only 1 returned significant P-values. Is there an explanation for this?
I tried a different data set and got a value that was not significant (PVAL > 0.05). I also displayed the answer in a long (15 digits) and exponential form and got 0.00000000000000e+000 using:
format longEng
I also checked with another statistics program that reported the p-value as < 0.0001. This means that the p-value is just really, really small.

Shifting rows of matrix in matlab

I have to shift certain rows in matlab. Like let say I have a matrix of size 50x50. And I have to shift certain rows lets say 15,18,45.. to the top and the remaining rows at the bottom. How can I accomplish this in matlab?
Have you tried the circshift function? Something like this could help:
A = [1:8; 11:18; 21:28; 31:38; 41:48]
A =
1 2 3 4 5 6 7 8
11 12 13 14 15 16 17 18
21 22 23 24 25 26 27 28
31 32 33 34 35 36 37 38
41 42 43 44 45 46 47 48
B = circshift(A, [3, 0])
B =
21 22 23 24 25 26 27 28
31 32 33 34 35 36 37 38
41 42 43 44 45 46 47 48
1 2 3 4 5 6 7 8
11 12 13 14 15 16 17 18
This is a problem that can be quite easily solved with the help of some simple indexing:
Matrix = [ 1 101 201 301
2 102 202 302
3 103 203 303
4 104 204 304
5 105 205 305
6 106 206 306
7 107 207 307
8 108 208 308
9 109 209 309
10 110 210 310];
rowsOnTop = [1 8 4];
rowsBelow = true(size(Matrix,1),1);
rowsBelow(rowsOnTop) = false;
Modified = [Matrix(rowsOnTop,:); Matrix(rowsBelow,:)]
Modified =
1 101 201 301
8 108 208 308
4 104 204 304
2 102 202 302
3 103 203 303
5 105 205 305
6 106 206 306
7 107 207 307
9 109 209 309
10 110 210 310
I understood that you want to move certain rows of matrix to the top and keep the rest on its place. For that you can use this:
Example matrix:
Matrix = [ 1:10; 101:110; 201:210; 301:310 ]';
Matrix =
1 101 201 301
2 102 202 302
3 103 203 303
4 104 204 304
5 105 205 305
6 106 206 306
7 107 207 307
8 108 208 308
9 109 209 309
10 110 210 310
Here's the code:
RowsVector = [ 3, 5, 8 ];
Edit: new better solution (presented here first because it's better).
NewMatrix = Matrix(cell2mat(arrayfun(#(x) x:size(Matrix,1):prod(size(Matrix)), [ RowsVector, setdiff(1:size(Matrix, 1), RowsVector) ]', 'UniformOutput', false)));
NewMatrix =
3 103 203 303
5 105 205 305
8 108 208 308
1 101 201 301
2 102 202 302
4 104 204 304
6 106 206 306
7 107 207 307
9 109 209 309
10 110 210 310
Edit: the rest of the answer is related to a [limited] older solution.
% RowsVector must be sorted, otherwise the reordering will fail.
Edit: fixed a bug with unordered RowsVector input.
RowsVector = sort(RowsVector);
for RowIndex = 1:size(RowsVector, 2)
row = RowsVector(RowIndex);
Matrix = vertcat(Matrix(row,:), Matrix);
Matrix(row+1,:) = [];
end
This is the result:
Matrix =
8 108 208 308
5 105 205 305
3 103 203 303
1 101 201 301
2 102 202 302
4 104 204 304
6 106 206 306
7 107 207 307
9 109 209 309
10 110 210 310
I'd solve this by defining a row permutation matrix to produce the desired result. If Matlab has a built-in function for this it escapes me, so I wrote one:
function P = rowpermat(vec)
P = zeros(length(vec));
for i = 1:length(vec)
P(i,vec(i)) = 1;
end
If vec is a permutation of 1:n this function will return a matrix which permutes the rows of an nxn matrix 1->vec(1), 2->vec(2), ... Note the absence of error checking and the like so use this in production code at your own risk.
In this case, if A is the matrix to permute, you might write:
rowpermat([15, 18, 45, 1:14,16:17,19:44,46:50])*A