Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9299417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:33:20+00:00 2026-06-18T22:33:20+00:00

I have data from an image processing program that I need to piece back

  • 0

I have data from an image processing program that I need to piece back together. My image data are originally an array of 18 (6 x 3) wells on a microscope slide, I need to number these wells consistently so I can identify what was in each well later on. I have the approximate x and y positions (in pixels) of the wells, and I want to sort them from left to right and then top to bottom (seems simplest) and number them 1 to 18.

like this:

     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    2    3    4    5    6
[2,]    7    8    9   10   11   12
[3,]   13   14   15   16   17   18

The caveats:

-Not all wells were picked up by the image processing program, so sometimes there are less than 18.

-Not all wells in the same row or column are on the exact same x or y, they seem to float around within 20-40 pixels.

-Not all images are centered on the same point or at the exact same magnification so well positions are not reliable enough to code for a range.

Example of data:

   Well BBXLeft BBYTop
1     0      39    637
2     1      43   1218
3     2     596    630
4     3     610   1212
5     4    1161    633
6     5    1164   1207
7     6    1710    623
8     7    1715   1202
9     8    2267    620
10    9    2271   1199
11   10    2824    617
12   11    2845   1197
13   12      35     57
14   13     593     53
15   14    1709     45
16   15    2262     41
17   16    2820     38

Or in reproducible form from dput:

wells <- structure(list(Well = 0:16, BBXLeft = c(39L, 43L, 596L, 610L,1161L, 1164L, 1710L, 1715L, 2267L, 2271L, 2824L, 2845L, 35L, 593L, 1709L, 2262L, 2820L), BBYTop = c(637L, 1218L, 630L, 1212L, 633L, 1207L, 623L, 1202L, 620L, 1199L, 617L, 1197L, 57L, 53L, 45L, 41L, 38L)), .Names = c("Well", "BBXLeft", "BBYTop"), class = "data.frame", row.names = c(NA, -17L))

Wells are out of order from image analysis program
This example missing well #15 (or 14 if count from 0)

Ideal output would be a new column with the left-right, top-bottom well numbers (or even “battleship” coordinates)

Sorry if this is a bit of a homework question but I really don’t know how to do this efficiently without hard-coding the cutoffs. I’m using R because it’s the only language I have a grasp on and I have other code ready to go written around this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:33:21+00:00Added an answer on June 18, 2026 at 10:33 pm

    The code below will help you to sort your wells according to the pixel location.
    However, perhaps more importantly is the following —
    These are your WellNumber labels plotted against the pixel location. Is this labeling scheme intentional, or are the well locations getting shuffled when labeling the image data?

    enter image description here


    In order to sort your data, we simply need a natural break, such as image size. In the example below I chose 500, but you can adjust as needed.

    # sort & plot the pixel corners, to get an idea for where the boundaries re
    sort(wells$BBXLeft)
    sort(wells$BBYTop)
    
    plot(x=wells$BBXLeft, y=wells$BBYTop)
    
    # add an NA for the missing value (we cant just ignore it)
    wells[18,] <- c(NA, 1100, 30) 
    
    imgSize <- 500
    nrows <- 3
    ncols <- 6
    
    # Assign row and col number based on boundaries set every 'imgSize'
    #  Note that rows are reversed, top to bottom
    wells$row <- cut(wells$BBYTop,  breaks=seq(imgSize*nrows, 0, -imgSize), label=1:nrows)
    wells$col <- cut(wells$BBXLeft, breaks=seq(0, imgSize*ncols, imgSize), label=1:ncols)
    
    # your battleship coordinates
    wells$battleship <- paste0("(", wells$row, ", ", wells$col, ")")
    
    
    # then to sort it,  sorting by rows, then by cols
    orderedWells <- wells$WellNo[order(wells$row, wells$col)]
    
    # if you want to lay it out nicely, use a matrix
    matrix(orderedWells, nrow=nrows, ncol=ncols, byrow=TRUE)
    
     #          [,1] [,2] [,3] [,4] [,5] [,6]
     #     [1,]   12   13   NA   14   15   16
     #     [2,]    0    2    4    6    8   10
     #     [3,]    1    3    5    7    9   11
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some array data returned from an ajax call consisting of an image
I have an array that is taken from an image using exif_read_data($image, 0, true)
I have data from two different sources that I need to combine. Some data
I have a page that is generating image data urls from a snapshot tool
We have an application that parses data from external sources and localizes it back,
I'm trying to display image data read in from a binary file (I have
I need to get some data from a column. For example I have data
I'm trying to do some processing with webworker on image data from canvas. Solution,
I have a Java application that is performing some realtime image processing, with the
I am writing an application that does some real-time processing on image data it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.