I am a newbie in MATLAB and I have a set of bmp images which I need to convert into pixel gray-level values as feature vectors of image. Can anyone suggest me the way how I can do that?
I need to use these pixel gray-level values as features and then perform operations like PCA/LDA.
I tried imread() but it returns me a matrix.. I feel feature vector will be just one row vector.
Regards,
imread() is the correct way to do it. Then just convert from a matrix into a vector. For example:
>> X = randi(255, 10)
X =
208 41 168 181 112 71 192 215 90 20
231 248 10 9 98 174 66 65 212 14
33 245 217 71 196 168 130 208 150 136
233 124 239 12 203 42 179 63 141 199
162 205 174 25 48 31 228 237 234 239
25 37 194 210 125 128 245 90 73 34
72 108 190 178 114 245 140 51 194 146
140 234 101 81 165 87 36 65 193 120
245 203 168 243 181 150 39 158 98 4
247 245 44 9 193 58 66 121 145 86
>> X(:)
ans =
208
231
33
233
162
25
72
140
245
247
...
Then you can just stack your different observations together with [] and do PCA.
Related
Adding a radial gradient to my SVG path seems to cause weird horizontal (anti-aliasing?) lines on some iOS devices or when you zoom in/out on an iOS device. I wasn't able to replicate it anywhere else.
Here's the (isolated) code:
<svg class="componentClass__chart-svg" width="335" height="318" viewBox="0 0 335 320" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="axesGradient" cx="50%" cy="0%" fx="50%" fy="0%" r="50%">
<stop stop-color="#FFFFFF" offset="10%"></stop>
<stop stop-color="#FFFFFF" offset="100%" stop-opacity="0.2"></stop>
</radialGradient>
</defs>
<path class="componentClass__axes" stroke-width="2" stroke="url(#axesGradient)" fill="none" d="M151 12 Q167 0 183 12 L319 108 Q335 120 329 139 L276 299 Q270 318 250 318 L85 318 Q65 318 59 299 L6 139 Q0 120 16 108 Z
M151 37 Q167 25 183 37 L293 116 Q309 128 303 147 L260 275 Q254 294 234 294 L101 294 Q81 294 75 275 L32 147 Q26 128 42 116 Z
M151 62 Q167 50 183 62 L267 124 Q283 136 277 155 L244 251 Q238 270 218 270 L117 270 Q97 270 91 251 L58 155 Q52 136 68 124 Z
M151 87 Q167 75 183 87 L241 132 Q257 144 251 163 L228 227 Q222 246 202 246 L133 246 Q113 246 107 227 L84 163 Q78 144 94 132 Z
M152 113 Q167 100 183 113 L215 139 Q231 152 224 171 L213 203 Q206 222 186 222 L149 222 Q129 222 122 203 L111 171 Q104 152 119 139 Z
" />
</svg>
And the issue:
SVG showing horizontal line
Note this doesn't happen on every iPhone or iPad, but you're usually able to replicate it when you try zooming in and out.
I was able to nail down the issue to this particular use case: as soon as you add the gradient to the stroke, it starts happening. If you change stroke="url(#axesGradient) to just stroke="#FFF", it doesn't seem to happen.
Is there any way I can optimize the SVG to prevent rendering issues?
Here's a Codepen with the exact code above.
Had the same problem, but in my case these lines appeared in any browser on IOS 16, updating to IOS 16.3 fixed it
I'm trying to export a collection from mongodb using mongoexport. This works so far:
mongoexport.exe --db dataloggin --collection p1 --out myRecords.json
The problem is that the file is huge and I can not open it anymore (araound 20GB, 30 days, every half a second a document).
I just need the data between the 3. March and the 5 March, so I tried to select this date range with the query selector as following:
mongoexport.exe --db dataloggin --collection p1 -q='{"timestamp":{"$gte":{"$timestamp":"2016-03-3T00:00:00.000Z"}:},"timestamp":{"$lt":{"$timestamp":"2016-03-05T00:00:00.000Z"}}}' --out myRecords.json
But I get an error:
error validating settings: query '[39 123 116 105 109 101 115 116 97 109 112 58 123 36 103 116 101 58 123 36 116 105 109 101 115 116 97 109 112 58 50 48 49 54 45 48 49 45 48 49 84 48 48 58 48 48 58 48 48 46 48 48 48 90 125 58 125 44 116 105 109 101 115 116 97 109 112 58 123 36 108 116 58 123 36 116 105 109 101 115 116 97 109 112 58 50 48 49 54 45 48 49 45 48 49 84 48 48 58 48 48 58 48 48 46 48 48 48 90 125 125 125 39]' is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}
Someone have an idea?
Many Thanks and regards
I want to use kernighan_lin_bisection from Networkx to separate a network data.
But the error below showed up and I'm stuck.
It would be highly appreciated if you could help me overcome this error.
QT-------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in ()
17 for c in init_partition:
18 for n in c:
---> 19 color_map_i[n]=colors[counter]
20 counter=counter+1
21
IndexError: list assignment index out of range
UNQT---------------------------------------------------------------------------
The coding I used and data source"200224_04_act.prn" are below.
QT---------------------------------------------------
G=nx.read_edgelist("200224_04_act.prn",nodetype=int)
colors=["red","blue","green"]
pos=nx.spring_layout(G)
init_nodes=np.array_split(G.nodes(),2)
init_partition=[set(init_nodes[0]),set(init_nodes[1])]
print(init_partition)
from networkx.algorithms.community import kernighan_lin_bisection
color_map_i=["black"]*nx.number_of_nodes(G)
print(color_map_i)
counter=0
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
print(color_map_i)
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_i)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
lst_b=kernighan_lin_bisection(G,partition=init_partition)
color_map_b=["black"]*nx.number_of_nodes(G)
counter=0
for c in lst_b:
for n in c:
color_map_b[n]=colors[counter]
counter=counter+1
nx.draw_networkx_edges(G,pos)
nx.draw_networkx_nodes(G,pos,node_color=color_map_b)
nx.draw_networkx_labels(G,pos)
plt.axis("off")
plt.show()
UNQT--------------------------------------------------------------
"200224_04_act.prn" below.(Number of nodes is around 2000 but I made it
small due to the limit of number of character)
1 415
2 415
3 415
3 1350
4 1351
5 1352
6 383
7 993
8 1353
9 887
10 887
11 887
12 887
13 887
14 1185
15 1185
16 1185
17 1185
18 1185
19 1146
20 1146
21 1146
22 1146
21 776
23 776
24 707
25 707
26 707
27 707
28 707
29 754
21 754
30 754
31 754
32 754
33 778
34 778
35 778
36 778
37 778
38 859
39 859
40 1354
41 563
42 563
43 563
44 563
45 563
46 1209
47 1209
48 1209
49 1209
50 1209
51 715
52 715
53 715
54 715
55 715
56 1048
57 1048
58 1047
59 1047
60 1047
61 1047
62 1047
63 718
64 718
65 718
66 718
67 718
68 947
17 947
69 947
70 889
71 744
72 744
73 744
74 744
75 744
76 1137
77 1137
78 1137
79 1137
80 612
81 612
82 612
83 612
17 612
84 790
85 790
86 790
87 790
88 790
89 922
90 922
91 922
92 922
93 922
21 738
94 738
95 738
96 738
97 738
98 1355
81 807
99 807
17 807
100 725
101 725
17 725
102 725
103 725
23 1046
104 661
105 661
106 661
107 661
108 661
109 907
110 907
111 907
112 907
113 907
114 840
115 840
116 840
117 840
17 840
118 759
23 759
119 759
23 761
120 761
121 761
122 761
123 1356
124 1265
125 1265
126 1265
127 1265
128 1265
129 894
29 894
130 894
131 894
132 667
133 667
124 758
134 758
135 758
122 758
136 758
137 471
138 471
You've got
for c in init_partition:
for n in c:
color_map_i[n]=colors[counter]
counter=counter+1
It looks to me like n will loop over all of the nodes of the graph. I do not see any entries in the graph that are 0. So probably the nodes are numbered 1 to N, while color_map_i is indexed from 0 to N-1. So it would break when n=N.
A good way to hunt for bugs like this in general would be to print n right before the line giving the error. This would give a hint to what the problem is.
I do hist calculation using OpenCV. I have the following implementation.
//Check image
for (int i = 0; i < block.rows; i++)
{
unsigned char *ptr = block.ptr<unsigned char>(i);
for (int j = 0; j < block.cols; j++)
{
cout << (int)ptr[j] << " ";
}
cout << endl;
}
//That gave
240 130 176 129 96 122 192 127 240 123 112 122 64 121 80 118 128 129 224 119
160 138 176 132 144 128 144 132 64 128 64 126 16 128 16 129 112 126 64 127
128 128 96 133 240 124 240 132 96 126 32 124 144 128 144 129 176 128 144 124
0 136 112 136 80 131 64 131 16 132 48 131 0 128 224 129 240 126 144 129
16 132 240 138 160 132 64 134 16 131 112 129 208 126 0 128 16 126 176 122
208 139 176 133 176 135 240 138 176 136 80 131 128 133 192 132 64 129 144 132
32 136 176 138 224 139 224 136 80 127 160 135 144 132 64 131 192 131 48 126
80 144 192 138 16 136 192 138 240 135 112 135 32 133 208 132 32 130 64 130
144 141 144 135 48 139 32 135 32 134 112 134 80 130 160 126 144 131 96 128
80 144 208 139 112 141 16 137 96 138 48 134 0 136 96 137 32 135 192 130
208 143 224 140 64 140 240 132 224 132 96 133 160 133 96 134 0 129 96 131
128 148 144 140 128 139 96 139 32 136 48 135 80 132 96 137 0 133 240 140
208 136 96 144 64 137 144 135 16 135 16 132 0 134 160 136 128 134 128 132
240 147 176 144 160 138 176 144 176 139 160 143 224 135 128 137 96 139 160 136
176 139 144 133 240 142 192 139 112 133 112 135 208 131 208 132 128 135 48 133
32 150 0 144 128 139 0 141 64 142 32 136 16 137 112 136 16 137 48 133
128 143 0 141 48 141 192 135 128 144 16 138 80 136 192 134 16 134 160 131
0 144 144 148 16 143 48 136 144 140 144 138 160 136 192 137 80 138 160 136
16 142 32 141 192 140 160 135 32 136 192 135 192 135 240 135 48 138 0 143
208 142 96 149 160 146 208 146 32 138 192 141 112 136 208 138 96 142 160 137
128 145 64 142 16 136 0 137 144 132 32 136 96 138 48 136 240 131 208 130
48 142 128 143 128 143 160 149 208 140 16 142 176 137 208 136 240 138 0 143
192 146 160 141 112 144 96 143 112 135 224 140 96 135 176 135 80 135 128 135
48 144 224 147 0 139 48 139 128 142 224 143 0 144 80 140 16 139 192 140
0 146 160 143 176 138 160 146 240 135 128 136 176 137 192 134 192 136 112 136
208 147 16 143 80 149 112 146 224 134 16 145 48 141 224 138 128 137 112 135
64 146 0 140 192 140 0 143 208 140 96 138 128 137 176 138 208 138 48 135
64 148 224 142 16 140 64 143 112 137 64 141 64 143 224 135 80 138 80 138
240 143 240 142 64 145 0 142 208 142 128 139 0 136 240 141 48 138 80 137
64 147 32 148 112 145 80 140 64 143 112 144 0 139 112 137 176 136 80 143
48 148 64 146 144 142 160 139 176 140 0 140 144 139 32 138 80 137 112 139
208 145 192 145 96 148 240 145 128 139 16 141 80 142 224 137 16 144 208 140
240 142 96 139 176 148 16 139 96 143 16 141 32 139 176 141 48 134 192 141
128 147 64 145 80 150 112 140 112 143 240 142 96 143 224 139 192 143 144 137
0 148 80 145 128 142 48 146 160 140 32 141 192 139 16 136 176 138 16 143
48 149 80 143 80 144 112 144 64 144 208 143 96 142 192 142 240 138 48 138
192 143 48 149 176 145 176 142 64 142 160 139 16 138 128 139 64 139 192 138
192 147 224 144 64 143 64 148 0 144 96 143 32 147 208 142 64 141 224 137
112 146 208 144 96 141 64 142 208 141 112 138 144 138 80 135 16 140 176 140
208 146 96 144 112 148 112 146 112 147 192 148 16 141 32 143 224 137 80 140
128 149 96 146 224 144 32 141 240 144 112 136 192 141 64 139 96 135 144 138
160 144 80 149 208 146 96 145 128 142 64 142 64 147 208 141 144 141 16 141
48 145 192 145 32 140 176 142 0 143 96 136 160 139 80 136 192 138 96 138
32 151 224 152 208 143 112 142 0 142 144 145 176 145 0 139 240 141 32 139
112 142 0 139 176 136 64 140 128 140 64 135 64 139 128 140 64 137 96 138
128 150 0 153 32 146 208 140 80 149 240 141 240 136 224 140 160 140 32 146
240 141 160 142 192 144 208 138 112 141 144 138 128 138 48 135 176 140 16 135
96 150 176 148 80 142 224 142 16 148 208 140 240 136 224 141 32 140 144 137
192 139 0 144 64 142 144 143 32 139 192 138 160 139 208 137 80 140 96 134
48 148 192 146 16 149 0 141 144 137 32 140 192 142 176 138 240 140 16 138
80 146 144 142 80 143 192 137 224 141 176 140 80 139 128 138 64 135 144 134
160 146 208 143 160 143 0 145 112 140 224 144 208 142 80 144 0 138 144 142
144 143 48 139 32 141 0 147 16 140 0 143 176 140 128 133 176 139 160 134
176 150 240 145 64 146 144 142 96 138 240 141 128 141 112 140 128 137 160 135
176 140 128 139 224 144 160 138 208 138 224 135 48 139 208 132 160 137 96 134
208 143 112 148 0 141 96 143 96 136 32 143 176 138 240 139 160 141 176 141
176 148 176 142 112 140 16 143 96 136 80 139 240 139 144 138 160 139 160 137
96 145 32 151 224 142 96 143 48 143 96 141 112 135 48 141 240 136 80 138
80 145 0 140 64 141 48 144 32 141 208 137 80 136 192 134 32 135 16 137
64 147 48 148 240 143 208 139 112 140 240 138 176 141 32 144 64 138 64 139
160 142 208 141 160 142 48 140 208 138 80 136 160 137 48 141 224 137 96 134
64 149 48 147 32 142 80 148 176 142 192 142 208 138 48 139 112 136 64 139
144 144 96 143 240 140 240 138 160 140 0 140 0 135 208 133 32 134 192 132
80 143 0 145 128 140 48 143 208 141 96 143 96 139 192 138 0 139 112 140
96 144 80 140 64 144 32 141 192 137 32 138 176 137 80 137 80 138 0 136
64 147 144 145 208 140 64 138 144 145 224 137 48 140 0 140 96 139 192 134
64 141 208 143 128 144 80 135 192 135 112 139 176 135 128 139 144 135 128 134
80 145 32 146 80 142 64 143 192 143 176 140 224 142 112 141 32 139 144 141
96 141 64 141 240 143 224 136 48 142 160 132 192 136 160 136 64 137 32 134
224 147 192 144 96 145 16 140 192 142 128 138 0 141 0 145 176 136 96 140
128 146 16 143 160 139 176 141 192 138 208 137 48 141 160 129 96 137 144 134
112 145 32 146 208 135 240 139 240 137 192 142 176 132 96 138 144 131 16 140
64 143 112 141 112 142 0 140 160 141 0 135 240 136 224 141 112 137 64 134
160 144 80 143 160 145 192 141 96 135 80 140 240 134 224 138 48 137 176 137
64 140 80 138 0 138 64 136 48 136 128 133 16 133 224 132 80 135 224 133
224 142 16 146 80 145 224 137 144 138 160 138 160 132 64 137 112 133 0 135
224 140 80 141 0 138 112 135 0 132 144 136 240 131 112 137 208 133 0 135
16 143 32 139 32 142 160 138 96 133 128 136 112 132 16 136 176 133 112 136
96 141 0 138 96 133 176 136 112 133 176 136 240 126 0 131 16 127 80 130
112 142 160 138 0 136 16 140 192 132 48 138 64 136 176 135 208 130 160 140
So pixel values are there.
//Histogram calculation
int histbin = 128;//quantize
int histSize[] = { histbin };
float range[] = { 0, 255 };
const float *ranges[] = { range };
Mat hist;
int channels[] = { 0};
calcHist(&block, 1, channels, Mat(), hist, 1, histSize, ranges, true, false);
//Print output
for (int h = 0; h < histbin; h++)
{
float binVal = hist.at<float>(h);
cout << " " << binVal;
}
I have outputs as follow.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
What is wrong with my implementation?
While it's easily done to visually outline, is it possible to have imagemagick output the coordinates of the outline of a transparent image?
Note, by outline, I don't mean just the bounding box border, but the actual contour around an arbitrarily shaped transparent image geometry.
Let's say you start with this image, which has a transparent background:
You can extract the transparency and find the edges like this:
convert penguin.png -alpha extract -edge 1 -threshold 50% edges.png
If, rather than an image, you want a list of the coordinates of the contour (i.e. the white pixels), you could do this instead:
convert penguin.png -alpha extract -edge 1 -threshold 50% -depth 8 txt: | awk -F: '/white/{print $1}'
256,0
253,1
254,1
255,1
257,1
258,1
259,1
253,2
259,2
252,3
253,3
...
...
Replace awk and everything after it with more to see what the awk is actually doing - it is just printing the coordinates of every pixel that is white.
The above pixels come out in row order, not like a contour where adjacent pixels come out together. If you want that, you might prefer to generate an SVG of the transparency with potrace like this:
convert penguin.png -alpha extract -threshold 50% pgm:- | potrace - --svg < alpha.pgm > result.svg
Output
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="500.000000pt" height="577.000000pt" viewBox="0 0 500.000000 577.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.13, written by Peter Selinger 2001-2015
</metadata>
<g transform="translate(0.000000,577.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M0 3294 l0 -2476 25 16 c31 20 104 21 152 1 20 -8 38 -14 40 -12 2 2
-8 35 -23 73 -49 129 -29 246 43 260 51 10 109 -12 159 -58 43 -40 44 -40 44
-15 0 41 60 120 99 130 28 7 32 11 26 30 -24 70 -15 385 16 637 44 346 171
715 351 1023 34 58 35 77 5 77 -43 0 -242 47 -277 65 -68 35 -196 130 -248
185 -83 86 -119 154 -153 286 -31 124 -38 237 -18 307 13 49 15 49 91 -15 177
-151 388 -309 477 -357 42 -23 108 -60 146 -81 76 -43 194 -83 228 -78 19 3
23 12 28 60 4 32 12 65 19 73 15 18 16 17 -35 34 -88 29 -255 122 -255 141 0
5 12 15 27 22 24 11 48 10 168 -9 77 -12 179 -22 226 -23 80 0 87 2 111 28 60
64 64 105 11 123 -21 6 -76 30 -122 51 l-84 39 -30 -21 c-21 -16 -32 -19 -40
-11 -19 19 8 54 63 84 46 25 59 27 109 22 31 -3 66 -8 79 -11 77 -16 -65 130
-178 182 -84 38 -150 45 -340 35 -225 -12 -242 -15 -322 -55 -57 -28 -68 -31
-68 -17 0 26 77 95 150 134 206 112 479 177 741 177 l97 0 -20 38 c-37 70 -10
186 68 294 54 75 56 88 23 119 -16 15 -29 36 -29 47 0 12 -4 24 -10 27 -19 12
-10 57 18 94 69 89 125 236 167 431 24 113 41 148 68 137 19 -7 43 -83 52
-162 l7 -60 33 90 c18 50 36 110 40 135 10 61 55 111 55 61 0 -11 9 -35 20
-54 29 -49 40 -235 17 -289 -9 -21 -12 -38 -8 -38 4 0 34 22 65 50 31 27 66
55 78 61 20 11 21 9 14 -22 -3 -18 -24 -72 -46 -119 -22 -48 -40 -90 -40 -94
0 -14 43 17 110 80 143 136 324 456 306 545 -4 21 -1 31 12 38 11 7 -402 10
-1260 11 l-1278 0 0 -2476z"/>
<path d="M2613 5669 c17 -82 18 -107 9 -133 -7 -18 -12 -47 -12 -64 0 -18 -14
-60 -31 -93 -17 -34 -28 -64 -25 -67 10 -10 49 17 129 88 43 39 84 70 92 70
23 0 17 -31 -15 -79 -17 -24 -30 -49 -30 -56 0 -6 -32 -58 -70 -115 -39 -56
-69 -104 -67 -106 4 -5 111 33 153 54 33 17 42 18 57 7 9 -7 17 -17 17 -23 0
-16 -104 -125 -134 -141 -14 -8 -26 -17 -26 -20 0 -4 23 -17 50 -30 53 -25
100 -63 100 -80 0 -19 -36 -30 -116 -36 -43 -3 -103 -8 -133 -11 l-54 -6 82
-80 c92 -90 185 -225 230 -331 34 -83 71 -217 71 -260 0 -15 5 -38 12 -50 18
-34 31 -169 29 -311 -1 -97 2 -133 12 -145 8 -9 29 -43 47 -76 19 -33 58 -96
87 -139 64 -93 107 -175 122 -233 10 -36 17 -44 49 -54 59 -18 220 -22 467 -9
127 6 316 15 420 20 184 9 267 15 311 25 46 10 364 35 451 35 64 0 93 -4 96
-12 3 -7 6 566 6 1275 l1 1287 -1204 0 -1203 0 20 -101z"/>
<path d="M4971 3138 c-20 -33 -89 -96 -165 -153 -23 -17 -103 -92 -179 -168
-77 -75 -145 -137 -153 -137 -8 0 -27 -21 -43 -47 -29 -47 -30 -47 -178 -99
-81 -29 -158 -53 -171 -53 -12 -1 -61 -15 -109 -31 -50 -18 -106 -30 -133 -30
-25 1 -101 -2 -170 -6 -100 -5 -136 -3 -179 10 -30 9 -70 16 -89 16 -33 0 -33
-1 -25 -32 4 -18 8 -92 8 -164 l0 -132 32 -20 c17 -12 70 -64 117 -117 68 -76
96 -119 140 -208 58 -118 106 -256 106 -302 0 -24 3 -26 23 -20 12 3 42 9 67
12 69 8 83 -18 98 -180 16 -176 45 -309 96 -446 24 -64 48 -129 54 -146 17
-50 52 -247 52 -295 0 -69 -42 -141 -129 -221 -99 -91 -141 -111 -239 -112
-91 -2 -129 14 -157 67 -23 42 -35 44 -76 14 -35 -26 -138 -36 -191 -19 -60
20 -78 45 -78 106 0 47 4 57 24 70 41 27 148 62 227 74 41 6 89 14 107 17 19
3 32 11 32 20 0 8 12 42 26 75 24 58 25 66 15 145 -7 57 -25 120 -57 204 -26
66 -50 120 -53 120 -16 -1 -49 -42 -73 -90 -56 -110 -125 -182 -277 -287 -66
-46 -158 -73 -248 -73 -82 0 -93 -4 -173 -65 -85 -65 -188 -116 -290 -143
-139 -38 -226 -46 -470 -45 -201 1 -250 4 -339 23 -57 12 -116 20 -130 17 -14
-3 -73 -22 -131 -42 -97 -34 -111 -37 -192 -33 l-87 4 -6 -40 c-4 -23 -9 -55
-12 -73 -7 -43 -51 -82 -104 -92 -25 -5 786 -9 1934 -10 l1977 -1 0 1585 c0
872 -2 1585 -4 1585 -2 0 -14 -15 -25 -32z"/>
<path d="M0 358 l0 -358 458 1 c393 1 450 2 407 14 -146 37 -255 105 -435 270
-30 28 -102 83 -160 122 -173 118 -218 166 -256 271 -11 32 -13 -14 -14 -320z"/>
</g>
</svg>
Assuming you have a transparent "input.png", first convert all nontransparent pixels to white, then use the "-edge" option to find the transitions between transparent and white:
convert input.png -negate -threshold 1 -edge 1 edge.png
Note that this will not only outline the image but will outline any "holes" in it as well. For example, try it with the built-in "logo:" image:
convert logo: -transparent white logotrans.png
convert logotrans.png -negate -threshold 1 -edge 1 t.png
which transforms this
to this