Pregunta

IMG_20251224_141625.jpgIMG_20251224_141625.jpg

Реши пожалуйста

Python

python
from PIL import Image, ImageEnhance img = Image.open('/mnt/data/IMG_20251224_141625.jpg') img.size (2619, 1805)

Python

python
import matplotlib.pyplot as plt, numpy as np plt.figure(figsize=(12,8)) plt.imshow(img) plt.axis('off') plt.show()

Python

python
img_rot = img.rotate(90, expand=True) # rotate counterclockwise? actually need upright plt.figure(figsize=(12,8)) plt.imshow(img_rot) plt.axis('off') plt.show()

Python

python
img_upright = img_rot.rotate(180, expand=True) plt.figure(figsize=(12,8)) plt.imshow(img_upright) plt.axis('off') plt.show()

Python

python
import numpy as np, matplotlib.pyplot as plt # crop central for main diagram arr = np.array(img_upright) h,w,_=arr.shape # approximate crop: remove top bars, focusing on rod drawing in upper half crop = arr[200:740, 300:2300] plt.figure(figsize=(12,4)) plt.imshow(crop) plt.axis('off') plt.show()

Python

python
crop2 = arr[420:1080, 450:2150] plt.figure(figsize=(12,4)) plt.imshow(crop2) plt.axis('off') plt.show()

Python

python
crop3 = arr[650:1240, 450:2150] plt.figure(figsize=(12,4)) plt.imshow(crop3) plt.axis('off') plt.show()

Python

python
# enlarge crop3 from PIL import Image crop3_img = Image.fromarray(crop3) crop3_img.size (1355, 590)

Python

python
plt.figure(figsize=(14,4)) plt.imshow(crop3_img.resize((2710,1180))) plt.axis('off') plt.show()

Python

python
import numpy as np, cv2, matplotlib.pyplot as plt, pandas as pd arr3 = np.array(crop3_img) # original resolution gray = cv2.cvtColor(arr3, cv2.COLOR_RGB2GRAY) # focus y band around rod (where rectangles are) # find y range by looking for darker pixels y_profile = gray.mean(axis=1) y_profile.min(), y_profile.max() (156.9520295202952, 254.66642066420664)

Python

python
# locate approximate y band for rod by thresholding on mean ys = np.where(y_profile < 240)[0] # rod is darker => lower mean ys[:10], ys[-10:], len(ys) (array([212, 213, 214, 216, 218, 219, 220, 221, 222, 223]), array([503, 504, 505, 506, 507, 508, 509, 510, 511, 512]), 90)

Python

python
# determine y with minimum mean to locate rod line min_y = y_profile.argmin() min_y 417

Python

python
# Show a slice with rod area by plotting coordinate grid import matplotlib.pyplot as plt plt.figure(figsize=(10,4)) plt.imshow(gray, cmap='gray') plt.axis('on') plt.show()

Python

python
rod_band = gray[400:470, :] # compute vertical edge profile in x by summing absolute gradient grad = np.abs(np.diff(rod_band.astype(float), axis=1)) x_profile = grad.mean(axis=0) x_profile.shape (1354,)

Python

python
# find peaks indicating vertical lines import scipy.signal as signal, numpy as np peaks, props = signal.find_peaks(x_profile, height=np.percentile(x_profile, 95), distance=30) len(peaks), peaks[:10], props['peak_heights'][:5] (11, array([145, 310, 345, 377, 436, 502, 571, 636, 696, 762]), array([30.98571429, 75.48571429, 29.75714286, 49.4 , 84.51428571]))

Python

python
peaks array([145, 310, 345, 377, 436, 502, 571, 636, 696, 762, 829])

Python

python
np.diff(peaks) array([165, 35, 32, 59, 66, 69, 65, 60, 66, 67])

Python

python
rod_band2 = gray[400:470, 250:900] grad2 = np.abs(np.diff(rod_band2.astype(float), axis=1)) x_prof2 = grad2.mean(axis=0) peaks2, props2 = signal.find_peaks(x_prof2, height=np.percentile(x_prof2, 92), distance=25) peaks2[:], len(peaks2) (array([ 60, 127, 186, 252, 321, 386, 446, 512, 579]), 9)

Python

python
abs_peaks = peaks2 + 250 abs_peaks array([310, 377, 436, 502, 571, 636, 696, 762, 829])

Python

python
peaks3, props3 = signal.find_peaks(x_prof2, height=np.percentile(x_prof2, 85), distance=25) len(peaks3), peaks3[:10], peaks3[-5:] (10, array([ 60, 95, 127, 186, 252, 321, 386, 446, 512, 579]), array([321, 386, 446, 512, 579]))

Python

python
import matplotlib.pyplot as plt plt.figure(figsize=(12,4)) plt.imshow(arr3) for x in abs_peaks: plt.axvline(x, color='red', linewidth=1) plt.axvline(250, color='blue') plt.axvline(900, color='blue') plt.ylim(500,350) plt.axis('off') plt.show()

Python

python
import cv2, numpy as np, matplotlib.pyplot as plt edges = cv2.Canny(rod_band2, 50, 150, apertureSize=3) lines = cv2.HoughLinesP(edges, rho=1, theta=np.pi/180, threshold=80, minLineLength=40, maxLineGap=5) len(lines) if lines is not None else None 32

Python

python
# filter near-vertical lines vert=[] for l in lines: x1,y1,x2,y2=l[0] if abs(x1-x2) < 3 and abs(y1-y2) > 40: vert.append((x1,y1,x2,y2)) len(vert), vert[:5] (0, [])

Python

python
lines = cv2.HoughLinesP(edges, rho=1, theta=np.pi/180, threshold=30, minLineLength=10, maxLineGap=3) vert=[] for l in lines: x1,y1,x2,y2=l[0] if abs(x1-x2) < 4 and abs(y1-y2) > 12: vert.append((x1,y1,x2,y2)) len(vert) 0

Python

python
band = gray[410:455, :] # rod height maybe 45 px # compute count of dark pixels per column dark = band < 150 counts = dark.sum(axis=0) # find peaks in counts peaks_counts, _ = signal.find_peaks(counts, height=np.percentile(counts, 90), distance=40) len(peaks_counts), peaks_counts[:10], counts[peaks_counts[:10]] (9, array([312, 373, 439, 505, 569, 632, 700, 765, 826]), array([33, 34, 39, 33, 33, 36, 34, 39, 34]))

Python

python
peaks_counts2, _ = signal.find_peaks(counts, height=np.percentile(counts, 80), distance=40) len(peaks_counts2), peaks_counts2[:15] (9, array([312, 373, 439, 505, 569, 632, 700, 765, 826]))

Python

python
# find top 20 columns by count top_idx = np.argsort(counts)[-30:] sorted(list(zip(top_idx, counts[top_idx])))[-10:] [(636, 34), (700, 34), (763, 39), (764, 39), (765, 39), (766, 39), (767, 39), (826, 34), (827, 33), (828, 33)]

Python

python
for x in range(250,330,5): print(x, counts[x])

Python

python
gray[430,280], gray[430,320], gray[430,300] (238, 222, 255)

Python

python
plt.figure(figsize=(10,3)) plt.imshow(gray, cmap='gray') plt.xlim(250, 870) plt.ylim(500,350) plt.show()

Python

python
band = gray[408:455, :] # includes border dark = band < 210 counts = dark.sum(axis=0) # get peaks with lower distance peaks_counts, props = signal.find_peaks(counts, height=15, distance=40) peaks_counts[:15], len(peaks_counts), props['peak_heights'][:5] (array([139, 315, 377, 442, 507, 570, 633, 701, 765, 825]), 10, array([19., 38., 38., 43., 38.]))

Python

python
xs_nonzero = np.where(counts>0)[0] xs_nonzero.min(), xs_nonzero.max() (4, 1004)

Python

python
row = gray[432,:] # find run where row<245 mask = row < 245 # find longest contiguous true run runs=[] start=None for i,v in enumerate(mask): if v and start is None: start=i if not v and start is not None: runs.append((start,i-1)) start=None if start is not None: runs.append((start,len(mask)-1)) # get runs longer than 100 runs_long = [r for r in runs if r[1]-r[0]>200] runs_long[:10], len(runs_long) ([], 0)

Python

python
band = gray[410:455,:] gradx = np.abs(np.diff(band.astype(float), axis=1)).mean(axis=0) # find peaks with high height peaks_edge, prop = signal.find_peaks(gradx, height=np.percentile(gradx, 96), distance=20) peaks_edge[:20], len(peaks_edge) (array([310, 377, 436, 502, 571, 636, 696, 762, 829]), 9)

Python

python
for x in range(270,340,5): print(x, gradx[x])

Python

python
# crop for options options = arr[1090:1600, 350:2300] plt.figure(figsize=(12,6)) plt.imshow(options) plt.axis('off') plt.show()

Python

python
options2 = arr[1350:1780, 350:2300] plt.figure(figsize=(12,4)) plt.imshow(options2) plt.axis('off') plt.show()

Python

python
options3 = arr[1650:2350, 250:2400] plt.figure(figsize=(12,6)) plt.imshow(options3) plt.axis('off') plt.show()

Pensamiento

Choosing the correct option for forces and solving static equilibrium

There are three options for force directions. The correct one has tension (T) pulling upwards, the weight (Mg) pulling downwards, and the support force (N) pushing upwards. Now, applying static equilibrium: T + N = Mg. For the moments, choose to take them about the point where the string is attached, and let's measure the distances from the left end (L/4, L/2, L/8) to solve for N.

Calculating forces using moments and equilibrium

To solve for the forces, I use the equilibrium condition for vertical forces and moments. First, I calculate N using the equation N = Mg*(x_Mg - x_T)/(x_N - x_T). After careful sign conventions, the distance calculations give N = 1.2 N and T = 1.8 N, rounded to one decimal place.

Thought for 5m 48s

Respuesta

  1. Верный рисунок — средний: натяжение нити TT направлено вверх, реакция опоры NN тоже вверх, вес MgMgвниз (в центре стержня).

По разметке: стержень поделен на 8 равных частей.
Точка нити — на границе 2-й и 3-й частей xT=28L\Rightarrow x_T=\frac{2}{8}L.
Опора — на границе 7-й и 8-й xN=78L\Rightarrow x_N=\frac{7}{8}L.
Центр масс — посередине xMg=48L\Rightarrow x_{Mg}=\frac{4}{8}L.

Моменты относительно точки нити:

N(xNxT)=Mg(xMgxT)N(x_N-x_T)=Mg(x_{Mg}-x_T) N(7828)L=Mg(4828)LN58L=Mg28LN=25Mg=0,4MgN\cdot\left(\frac{7}{8}-\frac{2}{8}\right)L=Mg\cdot\left(\frac{4}{8}-\frac{2}{8}\right)L \Rightarrow N\cdot\frac{5}{8}L=Mg\cdot\frac{2}{8}L \Rightarrow N=\frac{2}{5}Mg=0{,}4Mg

Сумма сил по вертикали:

T+N=MgT=MgN=0,6MgT+N=Mg \Rightarrow T=Mg-N=0{,}6Mg

M=300 г=0,3 кгM=300\text{ г}=0{,}3\text{ кг}, g=10 Н/кгg=10\text{ Н/кг}Mg=3 НMg=3\text{ Н}.

T=0{,}6\cdot 3=1{,}8\text{ Н}

3) $$ N=0{,}4\cdot 3=1{,}2\text{ Н}

Ответ: 1) средний рисунок; 2) T=1,8 НT=1{,}8\text{ Н}; 3) N=1,2 НN=1{,}2\text{ Н}.

Pregunta

IMG_20251224_144202.jpgIMG_20251224_144202.jpg

Реши пожалуйста

Python

python
from PIL import Image, ImageEnhance img = Image.open('/mnt/data/IMG_20251224_144202.jpg') img.size (2877, 1774)

Python

python
import matplotlib.pyplot as plt, numpy as np plt.figure(figsize=(12,7)) plt.imshow(img) plt.axis('off') plt.show()

Python

python
img_rot = img.rotate(90, expand=True) plt.figure(figsize=(10,14)) plt.imshow(img_rot) plt.axis('off') plt.show()

Python

python
img_rot2 = img.rotate(-90, expand=True) plt.figure(figsize=(10,14)) plt.imshow(img_rot2) plt.axis('off') plt.show()

Python

python
import numpy as np, matplotlib.pyplot as plt # crop around beam crop = img_rot2.crop((700,450,2200,1050)) plt.figure(figsize=(12,4)) plt.imshow(crop) plt.axis('off') plt.show()

Python

python
img_rot2.size (1774, 2877)

Python

python
# let's crop central region around beam y=1100? crop = img_rot2.crop((500,900,1300,1500)) plt.figure(figsize=(12,6)) plt.imshow(crop) plt.axis('off') plt.show()

Python

python
crop2 = img_rot2.crop((500,1020,1300,1420)) plt.figure(figsize=(14,5)) plt.imshow(crop2) plt.axis('off') plt.show()

Python

python
import numpy as np from PIL import ImageOps gray = ImageOps.grayscale(crop2) arr = np.array(gray) # take horizontal band around beam mid height h = arr.shape[0] band = arr[int(h*0.55):int(h*0.70), :] # likely around beam profile = band.mean(axis=0) # normalize import scipy.signal as signal, numpy as np # find local minima in profile # invert profile to find peaks at dark lines inv = profile.max()-profile peaks, props = signal.find_peaks(inv, distance=20, prominence=5) len(peaks), peaks[:10] (4, array([204, 235, 575, 599]))

Python

python
import matplotlib.pyplot as plt plt.figure(figsize=(12,3)) plt.plot(profile) plt.scatter(peaks, profile[peaks], color='r') plt.ylim(profile.min()-10, profile.max()+10) plt.show()

Python

python
enh = ImageEnhance.Contrast(crop2).enhance(2.5) enh = ImageEnhance.Sharpness(enh).enhance(2.0) plt.figure(figsize=(14,5)) plt.imshow(enh) plt.axis('off') plt.show()

Python

python
arr = np.array(ImageOps.grayscale(enh)) row_mean = arr.mean(axis=1) min_row = row_mean.argmin() min_row, row_mean[min_row], row_mean[:20].mean() (321, 76.46, 254.98587500000002)

Python

python
# find rows with mean below 200 rows = np.where(row_mean<200)[0] rows[:10], rows[-10:], len(rows) (array([315, 316, 317, 318, 319, 320, 321, 322, 323, 336]), array([322, 323, 336, 337, 338, 339, 340, 341, 342, 343]), 17)

Python

python
orig = ImageOps.grayscale(crop2) arr = np.array(orig) h,w = arr.shape # choose y around 250? let's find beam center by finding row with lowest std maybe; since beam adds contrast stds = arr.std(axis=1) stds.argmax(), stds.max() (340, 116.2310801740976)

Python

python
for y in range(200,260,10): print(y, stds[y], row_mean[y])

Python

python
band = arr[220:245,:] # 25 px band profile = band.mean(axis=0) inv=profile.max()-profile import scipy.signal as signal peaks,props=signal.find_peaks(inv, distance=30, prominence=10) len(peaks), peaks[:20], props['prominences'][:10] (2, array([204, 235]), array([133.16, 181.92]))

Python

python
import numpy as np from skimage import measure, morphology # use crop2 (original) or enhanced? let's use crop2 RGB to better isolate blue triangles and orange block. rgb = np.array(crop2) rgb.shape (400, 800, 3)

Python

python
gray = np.dot(rgb[...,:3],[0.299,0.587,0.114]) mask_dark = gray < 80 # remove small noise mask = morphology.remove_small_objects(mask_dark, min_size=50) # label components labels = measure.label(mask) props = measure.regionprops(labels) len(props) 5

Python

python
# list props areas and bbox for i,p in enumerate(sorted(props,key=lambda x: -x.area)): print(i, p.area, p.bbox, p.centroid)

Python

python
r,g,b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2] mask_blue = (b > 120) & (r < 120) & (g < 120) # rough mask_blue = morphology.remove_small_objects(mask_blue, min_size=200) labels=measure.label(mask_blue) props=measure.regionprops(labels) len(props), [p.area for p in props] (2, [1335.0, 1347.0])

Python

python
for p in props: print("bbox", p.bbox, "centroid", p.centroid)

Python

python
from skimage.morphology import dilation, square mask_beam2 = dilation(mask_beam, square(5)) mask_beam2 = morphology.remove_small_objects(mask_beam2, min_size=2000) labels=measure.label(mask_beam2) props=measure.regionprops(labels) len(props), [p.area for p in props] (0, [])

Python

python
pmax = sorted(props, key=lambda p: -p.area)[0] pmax.bbox, pmax.area ((320, 216, 340, 374), 3107.0)

Python

python
gray = np.dot(rgb[...,:3],[0.299,0.587,0.114]) dark = gray < 80 counts = dark.sum(axis=1) counts.argmax(), counts.max(), counts[:10] (320, 557, array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))

Python

python
for y in range(150,260,10): print(y, counts[y])

Python

python
band = dark[180:260,:] # but dark based on gray<80 or 60? Use gray<80 to capture black lines. dark80 = gray < 80 band = dark80[180:260,:] col_counts = band.sum(axis=0) # find columns with high dark count (vertical lines) thr = 10 cols = np.where(col_counts>thr)[0] cols[:20], cols[-20:], len(cols) (array([203, 204, 205, 206, 207, 218, 219, 220, 221, 222, 223, 233, 234, 235, 236, 237, 238]), array([203, 204, 205, 206, 207, 218, 219, 220, 221, 222, 223, 233, 234, 235, 236, 237, 238]), 17)

Python

python
dark120 = gray < 120 band = dark120[180:260,:] col_counts = band.sum(axis=0) thr=6 cols=np.where(col_counts>thr)[0] # group into clusters of consecutive columns clusters=[] start=cols[0] prev=cols[0] for c in cols[1:]: if c==prev+1: prev=c else: clusters.append((start,prev)) start=prev=c clusters.append((start,prev)) len(clusters), clusters[:10], clusters[-10:] (3, [(201, 209), (216, 223), (231, 239)], [(201, 209), (216, 223), (231, 239)])

Python

python
from skimage.feature import canny from skimage.transform import probabilistic_hough_line # use grayscale normalized gray_norm = gray/255.0 edges = canny(gray_norm, sigma=1.0, low_threshold=0.1, high_threshold=0.3) # restrict to ROI around beam (y 200-270) roi = edges[200:270,:] lines = probabilistic_hough_line(roi, threshold=10, line_length=20, line_gap=2) len(lines) 4

Python

python
lines [((245, 61), (190, 61)), ((238, 69), (196, 69)), ((199, 41), (204, 20)), ((236, 37), (240, 17))]

Python

python
roi = edges[210:310,:] # include divisions and maybe some support top lines = probabilistic_hough_line(roi, threshold=10, line_length=15, line_gap=2) len(lines) 22

Python

python
# classify vertical-ish lines by abs(dx) small vert=[] for (x0,y0),(x1,y1) in lines: dx=abs(x1-x0); dy=abs(y1-y0) if dx<=2 and dy>=10: vert.append(((x0,y0),(x1,y1))) len(vert), vert[:10] (6, [((247, 94), (247, 77)), ((240, 86), (240, 60)), ((193, 92), (194, 61)), ((186, 75), (186, 57)), ((248, 72), (248, 54)), ((185, 99), (186, 76))])

Python

python
rgb = np.array(crop2) r,g,b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2] # choose band y=235 to 265 maybe around beam area? but crop2 y axis 0-399; beam at ~200? # let's locate beam y band by checking where yellow pixels occur. yellow = (r>180)&(g>170)&(b>120)&(b<230) counts_y = yellow.sum(axis=1) # find rows with many yellow pixels top_rows = np.argsort(counts_y)[-10:] top_rows, counts_y[top_rows] (array([330, 333, 332, 331, 326, 325, 334, 329, 328, 327]), array([500, 501, 501, 501, 501, 501, 501, 502, 502, 504]))

Python

python
import matplotlib.pyplot as plt plt.figure(figsize=(12,4)) plt.imshow(crop2) plt.axis('on') plt.show()

Python

python
band = yellow[300:345,:] col_any = band.sum(axis=0) # count yellow pixels per col # columns with significant presence cols = np.where(col_any>5)[0] cols[0], cols[-1], len(cols) (135, 695, 505)

Python

python
x_left=135; x_right=695 Lpix=x_right-x_left x_support_L=292.99 # from centroid earlier x_support_R=610.6 print(Lpix, (x_support_L-x_left)/Lpix, (x_support_R-x_left)/Lpix)

Python

python
p=props[0] p.bbox, p.centroid ((269, 193, 315, 240), (291.5827751196172, 216.28373205741627))

Pensamiento

Verifying load and support positions

The centroid of the orange block at x=216.28x = 216.28 converts to approximately 1/7 of the beam's length. This positions the load at the first division (center of the first segment). The uniform board center is at 3.5/7L, with supports at 2/7L (left) and 6/7L (right). Next, I’ll compute distances based on the equation.

Checking the solution for consistency

I’ve solved for MM and mm with ( M

Thought for 7m 28s

Respuesta

Обозначим реакции опор: NлN_\text{л} и NпрN_\text{пр}. По условию

Nл=3Nпр.N_\text{л}=3N_\text{пр}.

Тогда из равновесия по вертикали:

Nл+Nпр=(M+m)g    3Nпр+Nпр=4Nпр=(M+m)g,N_\text{л}+N_\text{пр}=(M+m)g \;\Rightarrow\; 3N_\text{пр}+N_\text{пр}=4N_\text{пр}=(M+m)g, Nпр=(M+m)g4.N_\text{пр}=\frac{(M+m)g}{4}.

По рисунку стержень поделен на 7 равных частей:

  • груз mm стоит в точке x=17Lx=\frac{1}{7}L,
  • левая опора в точке x=27Lx=\frac{2}{7}L,
  • правая опора в точке x=67Lx=\frac{6}{7}L,
  • центр масс доски (масса MM) в точке x=12L=3.57Lx=\frac{1}{2}L=\frac{3.5}{7}L.

Составим моментный баланс относительно левой опоры (x=27Lx=\frac{2}{7}L):

Плечи:

  • до правой опоры: 67L27L=47L\frac{6}{7}L-\frac{2}{7}L=\frac{4}{7}L
  • до груза: 27L17L=17L\frac{2}{7}L-\frac{1}{7}L=\frac{1}{7}L
  • до центра масс доски: 3.57L27L=1.57L\frac{3.5}{7}L-\frac{2}{7}L=\frac{1.5}{7}L

Условие равновесия моментов:

Nпр47L+mg17L=Mg1.57L.N_\text{пр}\cdot \frac{4}{7}L + mg\cdot \frac{1}{7}L = Mg\cdot \frac{1.5}{7}L.

Сокращаем на 17gL\frac{1}{7}gL:

4Nпр+m=1.5M.4N_\text{пр} + m = 1.5M.

Но 4Nпр=(M+m)4N_\text{пр}=(M+m), значит:

(M+m)+m=1.5MM+2m=1.5M0.5M=2mM=4m.(M+m)+m = 1.5M \Rightarrow M+2m=1.5M \Rightarrow 0.5M=2m \Rightarrow M=4m.

Ответ: Mm=4.0\displaystyle \frac{M}{m}=4.0.

Compartir este Q&A