Fix blind-invert-matrix and increase percision of blind-to-text - blind - suckl… | |
git clone git://git.suckless.org/blind | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit e650c912ba86c84cdad466674a0ca0c4ebadef9c | |
parent b4a50a1ad6ab7d8a674ce54cde9778986badd333 | |
Author: Mattias Andrée <[email protected]> | |
Date: Fri, 14 Jul 2017 20:57:45 +0200 | |
Fix blind-invert-matrix and increase percision of blind-to-text | |
Signed-off-by: Mattias Andrée <[email protected]> | |
Diffstat: | |
M TODO | 5 +++++ | |
M man/blind-invert-matrix.1 | 5 +++++ | |
M man/blind-matrix-shear.1 | 4 +++- | |
M src/blind-invert-matrix.c | 12 +++++++----- | |
M src/blind-to-text.c | 4 ++-- | |
5 files changed, 22 insertions(+), 8 deletions(-) | |
--- | |
diff --git a/TODO b/TODO | |
@@ -1,3 +1,8 @@ | |
+HIGH PRIORITY: | |
+ blind-cat-rows and blind-cat-cols randomly produces incorrect results | |
+ | |
+ | |
+ | |
blind-transform affine transformation by matrix multiplication,… | |
improve quality on downscaling (pixels' neighb… | |
blind-primary-key replace a primary with transparency, -g for greyscale… | |
diff --git a/man/blind-invert-matrix.1 b/man/blind-invert-matrix.1 | |
@@ -21,6 +21,11 @@ resuling augment is printed. | |
.B -e | |
Apply optimisation that assumes all channels | |
are identical. | |
+.SH NOTES | |
+.B blind-invert-matrix | |
+fails if it encounters a non-invertable | |
+matrix, however, this is not always the | |
+case. | |
.SH SEE ALSO | |
.BR blind (7), | |
.BR blind-multiply-matrices (1), | |
diff --git a/man/blind-matrix-shear.1 b/man/blind-matrix-shear.1 | |
@@ -43,7 +43,9 @@ The description assumes the Y-axis grows downwards. | |
Horizontal shearing and vertical shearing is not | |
mutually commutative, this tool performs the | |
shearing at the same time rather than after each | |
-other. | |
+other. When shearing both horizontally and | |
+vertically, the transformation matrix is not | |
+necessarily invertable. | |
.SH SEE ALSO | |
.BR blind (7), | |
.BR blind-from-text (1), | |
diff --git a/src/blind-invert-matrix.c b/src/blind-invert-matrix.c | |
@@ -18,7 +18,7 @@ static int equal = 0; | |
typedef TYPE pixel_t[4];\ | |
size_t rn = stream->height, r1, r2, c;\ | |
size_t cn = stream->width > rn ? stream->width : 2 * rn;\ | |
- pixel_t *matrix = buf, *p1, *p2 = NULL;\ | |
+ pixel_t *matrix = buf, *p1, *p2;\ | |
TYPE t;\ | |
\ | |
for (r1 = 0; r1 < rn; r1++) {\ | |
@@ -29,7 +29,7 @@ static int equal = 0; | |
if (p2[r1][0])\ | |
break;\ | |
}\ | |
- if (r2 == rn)\ | |
+ if (r2 >= rn)\ | |
eprintf("matrix is not invertable\n");\ | |
for (c = 0; c < cn; c++)\ | |
t = p1[c][0], p1[c][0] = p2[c][0], p2[… | |
@@ -82,9 +82,11 @@ main(int argc, char *argv[]) | |
efflush(stdout, "<stdout>"); | |
if (!strcmp(stream.pixfmt, "xyza")) { | |
+ one = alloca(4 * sizeof(double)); | |
*(double *)one = 1; | |
process = process_lf; | |
} else if (!strcmp(stream.pixfmt, "xyza f")) { | |
+ one = alloca(4 * sizeof(float)); | |
*(float *)one = 1; | |
process = process_f; | |
} else { | |
@@ -105,7 +107,7 @@ main(int argc, char *argv[]) | |
for (y = stream.height; y--;) { | |
memmove(buf + y * row_size, buf + y * stream.r… | |
memset(buf + y * row_size + stream.row_size, 0… | |
- memcpy(buf + y * row_size + y * stream.pixel_s… | |
+ memcpy(buf + y * row_size + stream.row_size + … | |
} | |
} | |
if (equal) { | |
@@ -113,7 +115,7 @@ main(int argc, char *argv[]) | |
for (y = 0; y < stream.height; y++) { | |
for (x = 0; x < stream.width; x++) { | |
p = buf + y * row_size + x * stream.pi… | |
- memcpy(p + chan_size, p, chan_size); | |
+ memcpy(p, p + chan_size, chan_size); | |
memcpy(p + 2 * chan_size, p, 2 * chan_… | |
} | |
} | |
@@ -124,7 +126,7 @@ main(int argc, char *argv[]) | |
process(&stream, buf + 3 * chan_size); | |
} | |
for (y = 0; y < stream.height; y++) | |
- ewriteall(STDOUT_FILENO, buf + y * row_size + stream.r… | |
+ ewriteall(STDOUT_FILENO, buf + y * row_size + stream.c… | |
} | |
free(buf); | |
diff --git a/src/blind-to-text.c b/src/blind-to-text.c | |
@@ -16,8 +16,8 @@ USAGE("") | |
(CAST)(((TYPE *)(stream->buf + i))[3]));\ | |
} while (0) | |
-static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, do… | |
-static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, do… | |
+static void process_xyza (struct stream *stream, size_t n) {PROCESS(double, do… | |
+static void process_xyzaf(struct stream *stream, size_t n) {PROCESS(float, do… | |
int | |
main(int argc, char *argv[]) |