# Improve DensityHistogram running speed and return the density array

I want to plot lots of coordinate values with DensityHistogram function, such as:

data = RandomReal[1, {100000, 2}];
DensityHistogram[data, 50]


When the bin number is small, it will run fast, but as I have hundreds of thousands of coordinate data, I want to give a bigger bin number (maybe DensityHistogram[data, 1000]), which will be very slow or crash.

(In my real case, hundreds of thousands of data will form a specific shape)

I have another question is how to get the density matrix (DensityHistogram will give a density image, I think it can save time when replot it by ArrayPlot next time.)