This work develops theories and algorithms for computing rank-revealing QR factorizations (qRRQR) of quaternion matrices. First, by introducing a novel quaternion determinant, a quasi-Cramer's rule is established to investigate the existence theory of the qRRQR factorization of an mxn$$ m\times n $$ quaternion matrix A$$ \boldsymbol{A} $$. The proposed theory provides a systematic approach for selecting k$$ k $$ linearly independent columns of A$$ \boldsymbol{A} $$ in order to ensure that the resulting diagonal blocks R11$$ {\boldsymbol{R}}_{11} $$, R22$$ {\boldsymbol{R}}_{22} $$ of the R-factor possess rank revealing properties in both spectral and Frobenius norms. Secondly, by increasing the quaternion determinants of R11$$ {\boldsymbol{R}}_{11} $$ in each iteration by a factor of at least f-1$$ {f}<^>{-1} $$(0<f<1$$ 0<f<1 $$), a greedy algorithm with cyclic block pivoting strategy is derived to implement the qRRQR factorization. This algorithm costs about 32mnk+64(m-k)(n-k)logf-1n$$ 32 mnk+64\left(m-k\right)\left(n-k\right){\log}_{f<^>{-1}}n $$ real floating-point operations, which is as nearly efficient as quaternion QR with column pivoting for most problems. It also shows the effectiveness and reliability, particularly when dealing with a class of quaternion Kahan matrices. Furthermore, two improved greedy algorithms are proposed. Experiments evaluations are conducted on synthetic data as well as color image compression and quaternion signals denoising. The experimental results validate the usefulness and efficiency of our improved algorithm across various scenarios.