image axes modification/ pixel extension
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello guys,
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?
Thanks,
Amit.
0 Kommentare
Antworten (3)
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;
1 Kommentar
Image Analyst
am 25 Dez. 2022
Regarding your Answer, the first input to regionprops is your binary image. The image you segmented from the gray scale image to produce, basically, foreground and background in a binary image.
What exactly did you mean when you said "all calculation and axis of later created images "talk" with the pixelated axes"? I assumed you meant the whole collection of functions in the Image Processing Toolbox, such as regionprops, bwmorph, bwarea, etc.
You can certainly divide the coordinates in your CSV file by 30 to get pixel coordinates, and you're doing that, but I don't know what you mean by the subsequent calculations you want to do. You can certainly do voronoi on the original CSV values. I don't know what "ROI them properlym" means. Are you getting a labeled image from voronoi and then using regionprops on it? If you want the area of each region, you could use polyarea instead of reginprops to get area in original units instead of pixel units.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!