image axes modification/ pixel extension
3 Ansichten (letzte 30 Tage)
I wrote a code that imports PNG image (microscopre source, 30 nm pixel size) and overlays certain spot locations (mathematically, no pixels of course) on it which imported from a csv file.
The PNG is pixelated, so when I want to overlay the CSV points correctly, I must divide the CSV's data by the pixel size (30).
My problem with that is that all calculation and axis of later created images "talk" with the pixelated axes and not actual size (nm).
I would like somehow to 'enlrage'/'extend' the PNG file times 30 or some other solution that will conver the pixelated data to mathematical data (if I managed to clearify myself).
I saw somewhere that in the image tool box exists such a tool that make [1 2 3] to [111 222 333] if requested.
Do you think it will solve it? have any other idea?
Image Analyst am 25 Dez. 2022
True, all the image processing functions deal with pixels. If your CSV data is in nm, then you must divide by the number of nm per pixel AND round the values if you want the coordinates in pixels. But it depends on what you want to do with the CSV data. If you want to plot it in the overlay, you don't need to round the values. If you want to get the image value at the CSV location, you will need to round the value to the nearest pixel.
You can do what you ask with repelem but I don't recommend it. It will just enlarge your image unnecessarily. Doing that will give you roughly a spatial calibration factor of 1 nm per pixel, but you may still have a quantization problem if your nm per pixel is not an integer to begin with (for example 30.5 instead of 30).
The usual way we handle that is to do the computations, like with regionprops, in pixels. Then when it comes time to get real world values out of it we multiply the linear distances by the number of nm per pixel and the area metrics by the number of nm per pixel squared. For example
props = regionprops(mask, 'MajorAxisLength', 'Area');
allLengthsInPixels = [props.MajorAxisLength];
allAreasInPixels = [props.Area];
nmPerPixel = 30; % Define spatial calibration factor.
allLengthsInNm = allLengthsInPixels * nmPerPixel;
allAreasInSquareNm = allAreasInPixels * nmPerPixel ^ 2;