[R] Pixel Image Reshaping using R
Paul Bernal
p@u|bern@|07 @end|ng |rom gm@||@com
Thu Feb 24 18:01:27 CET 2022
Thank you very much Ivan!
El El jue, 24 de feb. de 2022 a la(s) 12:00 p. m., Ivan Krylov <
krylov.r00t using gmail.com> escribió:
> On Thu, 24 Feb 2022 11:00:08 -0500
> Paul Bernal <paulbernal07 using gmail.com> wrote:
>
> > Each pixel column in the training set has a name like pixel x, where
> > x is an integer between 0 and 783, inclusive. To locate this pixel on
> > the image, suppose that we have decomposed x as x = i ∗ 28 + j, where
> > i and j are integers between 0 and 27, inclusive.
>
> > I have been looking for information about how to process this with R,
> > but have not found anything yet.
>
> Given a 784-element vector x, you can reshape it into a 28 by 28 matrix:
>
> dim(x) <- c(28, 28)
>
> Or create a new matrix: matrix(x, 28, 28)
>
> Working with more dimensions is also possible. A matrix X with dim(X)
> == c(n, 784) can be transformed into a three-way array in place or
> copied into one:
>
> dim(X) <- c(dim(X)[1], 28, 28)
> array(X, c(dim(X)[1], 28, 28))
>
> (Replace 28,28 with 784 for an inverse transformation. In modern
> versions of R, two-way arrays are more or less the same as matrices,
> but old versions may disagree with that in some corner cases.)
>
> For more information, see ?dim, ?matrix, ?array.
>
> --
> Best regards,
> Ivan
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list